Wednesday, November 12, 2008

Could not load driver OracleDriver. Could not get JDBC Connection nested exception is SQLException: No suitable driver

I was working on Spring web services with Axis and I received this strange error related to my c3p0 connections:


java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver [[oracle.jdbc.driver.OracleDriver]]

Could not get JDBC Connection nested exception is SQLException: No suitable driver


It seems this is because my bean was containing some white spaces since I had copied the settings from other project. Here is the correct configuration for c3p0 with Oracle 9i


 <bean id="dataSourceC3PO" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>oracle.jdbc.OracleDriver</value>
</property>
<property name="jdbcUrl">
<value>jdbc:oracle:thin:@SERVER:1521:07</value>
</property>
<property name="user">
<value>USERNAME</value>
</property>
<property name="password">
<value>PASSWORD</value>
</property>
<property name="initialPoolSize">
<value>3</value>
</property>
<property name="acquireIncrement">
<value>3</value>
</property>
<property name="minPoolSize">
<value>1</value>
</property>
<property name="maxPoolSize">
<value>15</value>
</property>
<property name="maxStatementsPerConnection">
<value>100</value>
</property>
<property name="automaticTestTable">
<value>oracle_server</value>
</property>
<property name="numHelperThreads">
<value>20</value>
</property>
<property name="preferredTestQuery">
<value>select * from oracle_server</value>
</property>
</bean>



Do not forget to include Oracle driver ojdbc14.jar and c3po jar c3p0-0.9.1.2.jar in the class path.


Also, for those who need DBCP settings here they are:-


 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@SERVER:1521:07" />
<property name="username" value="USERNAME" />
<property name="password" value="PASSWORD" />
<property name="initialSize" value="2" />
<property name="maxActive" value="5" />
<property name="maxIdle" value="2" />
</bean>

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Thank you for your feedback