0
votes

I'm using oracle JDBC driver in a dynamic web application have this exception

...
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:315)
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:106)
... 56 more

however the driver should be correctly loaded while deployment a picture showing Deployment Assembly property with oracle driver in it

Edit: eclipse show me this warning after cleaning the project

Classpath entry xxxx/ojdbc6.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.      service     P/service   Classpath Dependency Validator Message

Edit: information about my system:

1- tomcat 8.5: I've the driver in $CATALINA_HOME/lib btw

2- oracle 11g [ojdbc6]: with HikariCP

3- eclipse 4.14.0: +maven using jersey webapp archetype

Edit: it worked previously with a normal (not web) project

Edit: this is how i had configured the datasource

        config.setJdbcUrl(jdbcUrl);
        config.setUsername(username);
        config.setPassword(passsword);
        config.addDataSourceProperty( "cachePrepStmts" , "true" );
        config.addDataSourceProperty( "prepStmtCacheSize" , "250" );
        config.addDataSourceProperty( "prepStmtCacheSqlLimit" , "2048" );         
        // config.addDataSourceProperty("driverClassName", "oracle.jdbc.driver.OracleDriver");
        config.setDriverClassName("oracle.jdbc.driver.OracleDriver")
    }
        ds = new HikariDataSource(config);
//some code

2
I see you are using Hikari with a relatively old Oracle driver (ojdbc6.jar). Try a newer Oracle JDBC JAR, depending on your Oracle version. Or, alternatively, try using the Hikari driverClassName property. The Hikari documentation for their jdbcUrl property mentions: "When using this property with "old" drivers, you may also need to set the driverClassName property". If I recall, the driver class name is simply "oracle.jdbc.OracleDriver". Others may correct me, if that is wrong. - andrewjames
@andrewjames I've tried this solution (driver class name) previously but it didn't work, it worked in another simple (not web) project though, that's why i assumed something related to the web might be the problem - Abdullah Khaled
@andrewjames I've tried to use a normal driver from DriverManager class but the driver wasn't found either. so now i think it is a problem related to tomcat - Abdullah Khaled
Please show how you configure your datasource, including the properties you set. A JDBC driver included inside a WAR needs to be explicitly loaded before it can be used (automatic driver loading only works for drivers on the initial classpath). - Mark Rotteveel
@MarkRotteveel done. I have added the ojdbc6.jar file to WEB-INF/lib manually is there anything else i can do? - Abdullah Khaled

2 Answers

0
votes

The only thing that worked for me so far is adding ojdbc6.jar manually to jvm libraries /lib/jvm/java-8-openjdk/jre/lib/ext then rebooting my machine. i know this screams BAD PRACTICE! because others will have to that too. i won't accept this answer, and waiting for a good solution.

0
votes

Can you take a look at Tomcat Servlet ?