Skip to content

JDBC: can not query gitbase #218

@bzz

Description

@bzz

In order to query gitbase though JDBC driver for MySQL

import java.sql.*;

class JdbcQueryGitbase {
  public static void main(String[] args) throws Exception {
    Class.forName("com.mysql.cj.jdbc.Driver");
    Connection connect = DriverManager
      .getConnection("jdbc:mysql://localhost:3306?user=root");
    
    Statement statement = connect.createStatement();
    ResultSet resultSet = statement
        .executeQuery("select * from repositories;");
    while (resultSet.next()) {
      System.out.println(resultSet.toString());
    }
  }
}

here is what I did

wget http://central.maven.org/maven2/mysql/mysql-connector-java/6.0.6/mysql-connector-java-6.0.6.jar
javac JdbcQueryGitbase.java
java -cp ".:mysql-connector-java-6.0.6.jar" JdbcQueryGitbase

it seems to have connected successfully but resulted in exception

Exception in thread "main" java.sql.SQLException: unknown error: table not found: dual
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
	at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
	at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1936)
	at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1422)
	at com.mysql.cj.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:2831)
	at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:2381)
	at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1739)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1596)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:633)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:347)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:270)
	at JdbcQueryGitbase.main(JdbcQueryGitbase.java:10)

the only thing in gitbase logs is

INFO[0017] NewConnection: client 1
INFO[0017] ConnectionClosed: client 1

Could you help me understand why does this happen and what is the best way to fix/avoid it?
Quick search landed me to https://en.wikipedia.org/wiki/DUAL_table but that was not super helpful.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions