Databricks Logs some error messages while trying to read data using databricks-jdbc dependency
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 10:08 AM
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.
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?
- Labels:
-
Data
-
Databricks Logs
-
Error Messages
-
Log4j
-
Logs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 10:56 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2023 09:39 AM
@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?

