Java application connection to dremio using dremio jdbc driver

I am new to dremio. I am trying to connect to dremio host using JDBC driver and fetch the SQL query output.

I have created a demo lab setup for this purpose and added sample data. I am trying below approach to connect:

    final String DB_URL = "jdbc:dremio:direct=//9047-<rest part of url>.university-labs.dremio.com:31010;";
    final String USER = "user";
    final String PASS = "password";
    Properties props = new Properties();
    props.setProperty("user",USER);
    props.setProperty("password",PASS);

    Connection conn = null;
    Statement stmt = null;
    try {

        conn = DriverManager.getConnection(DB_URL, props);

        stmt = conn.createStatement();

        String sql;
        sql = "SELECT * FROM incidents limit 5;";
        ResultSet rs = stmt.executeQuery(sql);
        HashMap<String, String> map = getResultSet(rs);
        rs.close();
        stmt.close();
        conn.close();
    } catch (SQLException se) {
        se.printStackTrace();
    }

I am running the application using the below command.

java -cp 20.0.0-202201050826310141-8cc7162b.jar Main.java

But I am getting the below error:

“No Suitable driver found for jdbc:dremio:direct=//9047-.university-labs.dremio.com:31010;”

If someone can answer the above, it will be very helpful.

Hi @Abhi,

You need to have the JDBC driver in the classpath of the application that you’re running, otherwise it will not be found. An example command is shown in the header comments from https://gist.github.com/narendrans/550860550fcebb3da1040aeb5ff31458, and java - Adding jdbc driver to classpath - Stack Overflow also has some additional instructions.

Best,
Kyle