从Google DataProc群集连接到Azure SQL时,获取Adal4j/Authentication Exception
请听我说。
我能够使用 apache spark Connector dataproc群集中。但是,在测试时,我有时发现SQL Server数据库不可用,因此,写操作失败了。
因此,我决定添加一个异常逻辑,以检查数据库在写入Azure DB之前是否可用使用以下代码,
var connection: Connection = null
val url = "jdbc:sqlserver://***.database.windows.net:1433;databaseName=some_db;encrypt=true;trustServerCertificate=true;authentication=ActiveDirectoryPassword"
val user = "xxxx"
val password = ******
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
connection = DriverManager.getConnection(url, user, password)
log.info(s"Successfully established connection on attempt: "+attempts)
return
}
此代码在我的本地计算机中正常工作。但是,尽管在DataProc中运行了相同的操作,但我遇到以下错误,
Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/aad/adal4j/AuthenticationException
我已经走了相似的问题在SO中进行了讨论。但这对我来说有所不同,因为要编写到SQL Server的Apache Spark连接器工作正常。我只想让代码drivermanager.getConnection(url,用户,密码)
在我写之前测试连接。
Please hear me out.
I am able to successfully write to Azure SQL server table using Apache Spark connector in Dataproc cluster. But then while testing I found sometime that the SQL server database in not available and because of this the write operation fails.
So, I decided to add an exception logic to check if the database is available or not using the following code before writing to Azure DB,
var connection: Connection = null
val url = "jdbc:sqlserver://***.database.windows.net:1433;databaseName=some_db;encrypt=true;trustServerCertificate=true;authentication=ActiveDirectoryPassword"
val user = "xxxx"
val password = ******
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
connection = DriverManager.getConnection(url, user, password)
log.info(s"Successfully established connection on attempt: "+attempts)
return
}
This code works fine in my local machine. But while running the same in Dataproc I am getting the below error,
Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/aad/adal4j/AuthenticationException
I already went though this similar issue discussed in SO. But it's bit different for me as the Apache Spark connector to write to SQL server is working fine. I just want to have the code DriverManager.getConnection(url, user, password)
work to test the connection before my write.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论