[英]How to establish a Microsoft azure databricks delta tables connection using spring boot just like mysql,sql server
Hi I want to establish a connection with the Microsoft azure databricks delta table inside my spring boot application.I have the cluster url,username and the password(token) of the delta table from which I need to pull the data to my application. Hi I want to establish a connection with the Microsoft azure databricks delta table inside my spring boot application.I have the cluster url,username and the password(token) of the delta table from which I need to pull the data to my application. Kindly shed some light on this
请对此有所了解
You can access cluster & underlying tables using the JDBC (see documentation ).您可以使用 JDBC 访问集群和基础表(请参阅文档)。 You need to get the corresponding driver, and add it to your application, and then just use normal JDBC API , like this:
您需要获取相应的驱动程序,并将其添加到您的应用程序中,然后使用普通的 JDBC API ,如下所示:
String jdbcConnectPassthroughCluster = "jdbc:spark://<server-hostname>:443/default;transportMode=http;ssl=1;httpPath=sql/protocolv1/o/0/xxxx-xxxxxx-xxxxxxxx;AuthMech=3;UID=token;PWD=";
String PATH = "<personal token>"
String JDBC_DRIVER = "com.simba.spark.jdbc.Driver";
String DB_URL = jdbcConnectPassthroughCluster + PAT;
Class.forName(JDBC_DRIVER);
System.out.println("Getting connection");
Connection conn = DriverManager.getConnection(DB_URL);
Statement stmt = conn.createStatement();
System.out.println("Going to execute query");
ResultSet rs = stmt.executeQuery("select * from table");
System.out.println("Query is executed");
int i = 0;
while(rs.next()) {
System.out.println("Row " + i + "=" + rs.getLong(1));
i++;
}
rs.close();
stmt.close();
conn.close();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.