DataSource : Cannot create JDBC driver of class '' for connect URL ' - Java - Programmation
Marsh Posté le 13-03-2004 à 19:54:40
en fait, mon DataSource ne se rempli apparement pas
mon datacontexte = "jdbc/anzadb"
et enfin, j'ai bien declaré mon datasource dans mon web.xml :
<web-app>
<display-name>JSP-TEST-JBUILDER</display-name>
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/anzadb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
j'ai ajouté ce qu'il faut dans le server.xml de mon tomcat mais sans etre sur du resultat :
<Context path="/JSP-TEST-JBUILDER" docBase="TEST"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<ResourceParams name="jdbc/anzadb">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>pzmu9wvq</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://192.168.0.2:3306/anzadb?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
pleazzz help !
Marsh Posté le 13-03-2004 à 19:02:46
bj,
je cherche à faire un pool connection sur mon tomcat pour mon projet en jsp.
ma base est mysql.. j'ai mis les jar dans le common/lib de mon tomcat.
je developpe sous jbuilder, mon code est correct mais cé la configuration de tomcat qui me pose soucis.
kk'un aurait deja mis ca sur place?
voici mon code java :
private boolean makePoolConnection(Context context) {
try {
String datacontext = MySqlDbInfo.getString("tomcat.datacontext" );
System.out.println("DataSource : " + datacontext);
DataSource ds = (DataSource) context.lookup(datacontext);
dbConnection = ds.getConnection();
System.out.println("Connexion à la base de données en pool" );
isConnected = true;
return true;
}
catch (Exception ex) {
ex.printStackTrace();
return false;
}
}
mon erreur est :
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause:
java.sql.SQLException: No suitable driver
merci d'avance!