cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Databricks Logs some error messages while trying to read data using databricks-jdbc dependency

Binesh
New Contributor II

I have tried to read data from Databricks using the following java code.

String TOKEN = "token...";
String url = "url...";
 
Properties properties = new Properties();
properties.setProperty("user", "token");
properties.setProperty("PWD", TOKEN);
 
Connection connection = DriverManager.getConnection(url, properties);
String query = "select * from schema.table";
 
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(query);
 
while(rs.next()) {
    int colCount = rs.getMetaData().getColumnCount();
    for(int col=1; col<=colCount; col++){
        System.out.print(rs.getString(col) + " ");
    }
 
    System.out.println();
}

But every time when I run this java program, some errors are being logged by StatusLogger and I don't know how to resolve those errors.

Logger Errors 

Note:

  • Apart from databricks-jdbc dependency, I also have log4j as a dependency.

Things I have noticed:

  • If I remove log4j from my dependency, no errors are being logged in the console.

Can someone please help me resolving this issue?

Can someone also please explain me why databricks-jdbc has an internal log4j instead of using log4j as its dependency?

2 REPLIES 2

shan_chandra
Esteemed Contributor

@Binesh J​ - The issue could be due to the data type of the column is not compatible with getString() method in line#17. use getObject() method to retrieve the value as a generic value and then convert to string.

Binesh
New Contributor II

@Shanmugavel Chandrakasu​  - Thanks for the reply.

I have tried using the getObject() method in line#17 but I can still see those error logs in my console. I have tried debugging my program and found out that these exceptions were logged when line#14 is getting executed.

Can you also please explain to me why databricks-jdbc has an internal log4j instead of using log4j as its dependency?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group