程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何像mysql、sql server一样使用spring boot建立Microsoft azure databricks delta表连接大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决如何像mysql、sql server一样使用spring boot建立Microsoft azure databricks delta表连接?

开发过程中遇到如何像mysql、sql server一样使用spring boot建立Microsoft azure databricks delta表连接的问题如何解决?下面主要结合日常开发的经验,给出你关于如何像mysql、sql server一样使用spring boot建立Microsoft azure databricks delta表连接的解决方法建议,希望对你解决如何像mysql、sql server一样使用spring boot建立Microsoft azure databricks delta表连接有所启发或帮助;

您好,我想在 Spring Boot 应用程序中建立与 Microsoft azure databricks delta 表的连接。我有集群 url、用户名和 delta 表的密码(令牌),我需要从中提取数据到我的应用。请对此有所了解

解决方法

您可以使用 JDBC 访问集群和底层表(请参阅 documentation)。您需要获取相应的驱动程序,并将其添加到您的应用程序中,然后只需使用普通的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();

大佬总结

以上是大佬教程为你收集整理的如何像mysql、sql server一样使用spring boot建立Microsoft azure databricks delta表连接全部内容,希望文章能够帮你解决如何像mysql、sql server一样使用spring boot建立Microsoft azure databricks delta表连接所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。