Tomcat - No suitable driver found for jdbc:avatica:remote:url=...

767 views
Skip to first unread message

FrankieBass

unread,
Sep 27, 2017, 10:07:31 AM9/27/17
to Druid User
Hi,

I am developing a web app in Eclipse, using Maven and Jetty. The application uses JDBC to Druid and it works without any problems in Jetty. If I try to run the application in Tomcat (internal in Eclipse or external) I get the following error

java.sql.SQLException: No suitable driver found for jdbc:avatica:remote:url=http://localhost:18082/druid/v2/sql/avatica/
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at DruidDao.getConnection(DruidDao.java:939)

My pom.xml has the following dependencies for the jdbc driver

<dependency>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.calcite.avatica</groupId>
<artifactId>avatica-server</artifactId>
<version>1.10.0</version>
</dependency>

I have copied all jars in the WEB-INF/lib of my app as well ad in the lib dir of Tomcat, but I always get the same error. If I add the following code

        try {
            Class.forName("org.apache.calcite.jdbc.Driver");
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        }


I get a no class found exception (only in tomcat)... why this inconsistent behaviour? How to fix errors in Tomcat?

Thank you in advance for any help.

Cheers

FrankieBass

unread,
Sep 27, 2017, 10:31:24 AM9/27/17
to Druid User
Hi

I have figured it out, the correct driver to instantiate is

        try {
            Class.forName("org.apache.calcite.avatica.remote.Driver");            
        } catch (ClassNotFoundException e1) {
            e1.printStackTrace();
        }


Now it works. It would be useful to add it to the documentation.

Cheers!
Reply all
Reply to author
Forward
0 new messages