cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Honored Contributor III
Honored Contributor III

@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?

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.