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:
Things I have noticed:
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?
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.
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?
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.