mmolimar / ksql-jdbc-driver

JDBC driver for Apache Kafka
Apache License 2.0
87 stars 19 forks source link

ClassNotFoundException #27

Open NitishDhok123 opened 4 years ago

NitishDhok123 commented 4 years ago

confluent

I am trying to connect to ksqldb public class MainClass {

public static void main(String[] args) {
    try {
        Class.forName("com.github.mmolimar.ksql.jdbc.KsqlDriver");
        KsqlDriver driver=new KsqlDriver();
        String url="jdbc:ksql://localhost:8089";

        KsqlConnection con=driver.buildConnection(KsqlDriver.parseUrl(url), null);
        Statement st=con.createStatement();
        ResultSet rs=st.executeQuery("select * from KSQLTEST");

        while(rs.next()) {
            System.out.println(rs.getString(0));
        }
    } catch (ClassNotFoundException | SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

}

but I m facing this issue Exception in thread "main" java.lang.NoClassDefFoundError: io/confluent/ksql/rest/client/KsqlRestClient at com.github.mmolimar.ksql.jdbc.KsqlConnection.init(KsqlConnection.scala:177) at com.github.mmolimar.ksql.jdbc.KsqlConnection.(KsqlConnection.scala:163) at com.github.mmolimar.ksql.jdbc.KsqlDriver.buildConnection(KsqlDriver.scala:71) at com.torana.ksqldemo.MainClass.main(MainClass.java:21) Caused by: java.lang.ClassNotFoundException: io.confluent.ksql.rest.client.KsqlRestClient at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 4 more

mmolimar commented 4 years ago

Hi. Is the classpath properly set? I mean, all dependencies the driver has are included?

NitishDhok123 commented 4 years ago

yes can you tell me list of dependency that are need to connect

mmolimar commented 4 years ago

When you build the project with sbt clean assembly all deps are in the fat jar.