commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garey Mills <gmi...@berkeley.edu>
Subject Re: Continuing problems with dbcp - no suitable driver -- please help
Date Fri, 16 Mar 2007 22:29:05 GMT

    Just an note on this, I set the 'jdbc.drivers' system property in a 
ServletContextListener like this


     Properties p = new Properties(System.getProperties());

     p.setProperty("jdbc.drivers", 
"com.mysql.jdbc.Driver:org.apache.commons.dbcp.PoolingDriver");

     System.setProperties(p);


    After setting the 'com.mysql.jdbc.Driver' the error persists, but 
the PoolingDriver isn't called, so I just get:

java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getConnection(DriverManager.java:545)
        at java.sql.DriverManager.getConnection(DriverManager.java:193)


Garey Mills wrote:
> Hello -
>
>    I am trying to use dbcp in a java web app, using it as a driver and 
> configuring it with a jocl file. Here is the error I am getting
>
> java.sql.SQLException: No suitable driver
>        at java.sql.DriverManager.getConnection(DriverManager.java:545)
>        at java.sql.DriverManager.getConnection(DriverManager.java:193)
>        at 
> org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:46)

>
>        at 
> org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)

>
>        at 
> org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:840)

>
>        at 
> org.apache.commons.dbcp.PoolingDriver.connect(PoolingDriver.java:175)
>        at java.sql.DriverManager.getConnection(DriverManager.java:525)
>        at java.sql.DriverManager.getConnection(DriverManager.java:193)
>
> and here is the jocl file, 'dbconn.jocl'
>
> <object class="org.apache.commons.dbcp.PoolableConnectionFactory" 
> xmlns="http://apache.org/xml/xmlns/jakarta/commons/jocl">
>   <!-- the first argument is the ConnectionFactory -->
>   <object class="org.apache.commons.dbcp.DriverManagerConnectionFactory">
>      <string value="jdbc:mysql://localhost/<dbname>?user=<my 
> user>&amp;password=<my password>"/>
>      <object class="java.util.Properties" null="true"/>
>   </object>
>   <!-- the next argument is the ObjectPool -->
>   <object class="org.apache.commons.pool.impl.GenericObjectPool">
>      <object class="org.apache.commons.pool.PoolableObjectFactory" 
> null="true"/>
>      <int value="10"/> <!-- max active -->
>      <byte value="1"/> <!-- when exhausted action, 0 = fail, 1 = 
> block, 2 = grow -->
>      <long value="2000"/> <!-- max wait -->
>      <int value="10"/> <!-- max idle -->
>      <boolean value="false"/> <!-- test on borrow -->
>      <boolean value="false"/> <!-- test on return -->
>      <long value="10000"/> <!-- time between eviction runs -->
>      <int value="5"/> <!-- number of connections to test per eviction 
> run -->
>      <long value="5000"/> <!-- min evictable idle time -->
>      <boolean value="true"/> <!-- test while idle -->
>   </object>
>  <!-- the next argument is the KeyedObjectPoolFactory -->
>  <object 
> class="org.apache.commons.pool.impl.StackKeyedObjectPoolFactory">
>     <int value="5"/> <!-- max idle -->        </object>
>   <string value="SELECT COUNT(*) FROM DUAL"/> <!-- validation query -->
>   <boolean value="false"/> <!-- default read only -->
>   <boolean value="true"/> <!-- default auto commit -->
> </object>
>
> in my code, I try to make a connection like this
>
>        Connection c = 
> DriverManager.getConnection("jdbc:apache:commons:dbcp:/dbconn");
>
> It looks like the connection is not being made by the PoolingDriver, 
> but I can connect to the database
> using <my user>, <my password> and <dbname>.
>
> Can anyone help me out?
>
> Garey Mills
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message