Announcement Announcement Module
Collapse
No announcement yet.
oracle JDBC throws error while initializing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • oracle JDBC throws error while initializing

    Hello everyone ,

    This is how my config file looks like

    <!-- DB CONNECTION TO A ORACLE DATABASE -->
    <bean id="dataSourceORACLE" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName"><value>oracle.jdbc.driver.O racleDriver</value></property>
    <property name="url"><value>jdbc:oracle:thin:@someip:1521:SI D</value></property>
    <property name="username"><value>username</value></property>
    <property name="password"><value>password</value></property>
    </bean>

    And my JdbcTemplate uses it ,

    <!-- Init a JdbcTemplate bean with the specific DataSource -->
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
    <property name="dataSource"><ref local="dataSourceORACLE" /></property>
    </bean>


    But when i compile my code in the logs i get the following

    2005-04-05 08:37:13,486 DEBUG [org.springframework.jdbc.datasource.DataSourceUtil s] - <Opening JDBC connection>
    2005-04-05 08:37:13,490 WARN [org.springframework.jdbc.support.SQLErrorCodesFact ory] - <Error while extracting database product name - falling back to empty error codes>
    org.springframework.jdbc.support.MetaDataAccessExc eption: Could not get Connection for extracting meta data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionEx ception: Could not get JDBC connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
    org.springframework.jdbc.CannotGetJdbcConnectionEx ception: Could not get JDBC connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
    org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver', cause:
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at org.apache.catalina.loader.StandardClassLoader.loa dClass(StandardClassLoader.java:945)
    at org.apache.catalina.loader.StandardClassLoader.loa dClass(StandardClassLoader.java:810)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:302)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:141)
    at org.apache.commons.dbcp.BasicDataSource.createData Source(BasicDataSource.java:730)
    at org.apache.commons.dbcp.BasicDataSource.getConnect ion(BasicDataSource.java:518)
    at org.springframework.jdbc.datasource.DataSourceUtil s.doGetConnection(DataSourceUtils.java:146)
    at org.springframework.jdbc.datasource.DataSourceUtil s.getConnection(DataSourceUtils.java:100)
    at org.springframework.jdbc.datasource.DataSourceUtil s.getConnection(DataSourceUtils.java:76)
    at org.springframework.jdbc.support.JdbcUtils.extract DatabaseMetaData(JdbcUtils.java:133)
    at org.springframework.jdbc.support.JdbcUtils.extract DatabaseMetaData(JdbcUtils.java:173)
    at org.springframework.jdbc.support.SQLErrorCodesFact ory.getErrorCodes(SQLErrorCodesFactory.java:185)
    at org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator.setDataSource(SQLErrorCodeSQLExc eptionTranslator.java:113)
    at org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator.<init>(SQLErrorCodeSQLExceptionT ranslator.java:92)
    at org.springframework.jdbc.support.JdbcAccessor.getE xceptionTranslator(JdbcAccessor.java:81)
    at org.springframework.jdbc.support.JdbcAccessor.afte rPropertiesSet(JdbcAccessor.java:117)
    at org.springframework.jdbc.core.JdbcTemplate.afterPr opertiesSet(JdbcTemplate.java:194)
    ....


    I do have the jar class in my lib, and my classpath and permisions seem the same as other jars in the same lib. I also use DB visualizer with this same jar file hence connecting to the db with no problem.

    So any ideas ?
    Thank you

  • #2
    Can you do a new oracle.jdbc.driver.OracleDriver() in the same application? It might be that a class that OracleDriver depends on is not loadable.

    Rob

    Comment


    • #3
      Was able to call OracleDriver

      I was able to do the following ,

      OracleDriver od = new OracleDriver();

      and compiled and when the method in which this variable was defined was called it didn't throw any exceptions.

      the import statement

      import oracle.jdbc.*;

      But the same error with the first posting still persists

      Comment


      • #4
        Figured out what the problem was , the jar should be in the tomcat common/lib not in the app's lib. After doing that it doesn't throw the above error . So it seems to be working for now. The connection part at least not my code :?

        Thank you

        Comment


        • #5
          Originally posted by kkrikor View Post
          Figured out what the problem was , the jar should be in the tomcat common/lib not in the app's lib. After doing that it doesn't throw the above error . So it seems to be working for now. The connection part at least not my code :?

          Thank you

          Thanks Man! your post helped a lot, was facing the same issue.. resolved via placing the respective jar under tomcat/lib directory..

          Comment

          Working...
          X