java.sql.SQLException:未找到适合jdbc:sqlserver://的驱动程序-基于Java的Azure函数

肯尼:

我有基于Java的Azure函数,它正在写入Azure SQL。但是触发函数时出现错误。我需要使用VS Code处理驱动程序问题吗?我对JDBC或任何其他与Azure Functions最佳的驱动器都很好

https://docs.microsoft.com/zh-cn/sql/connect/jdbc/step-3-proof-of-concept-connecting-to-sql-using-java?view=sql-server-ver15

ERROR:

17.4.2020 13.06.39] java.sql.SQLException: No suitable driver found for jdbc:sqlserver://sql...;
[17.4.2020 13.06.39] Function "TopicTriggerSQLOutput" (Id: 70a1ce4c-3828-4280-81cf-dafa61956cb5) 
invoked by Java Worker
[17.4.2020 13.06.39]    at java.sql.DriverManager.getConnection(DriverManager.java:689)

CODE:

package com.function;
import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;

/**
 * Azure Functions with Azure Storage Queue trigger.
 */
public class TopicTriggerSQLOutput {
     /**
     * This function will be invoked when a new message is received at the specified path. The 
message contents are provided as input to this function.
     */
     @FunctionName("TopicTriggerSQLOutput")
     public void run(
         @ServiceBusTopicTrigger(
            name = "message",
            topicName = "newtopic",
            subscriptionName = "newsubscription",
            connection = "topicconnstring"
        ) String message,
         final ExecutionContext context
    ) {
         /*Creating SQL Connection. I need help here:
         https://docs.microsoft.com/en-us/sql/connect/jdbc/step-3-proof-of-concept-connecting-to-sql- 
   using-java?view=sql-server-ver15
        */

            String connectionUrl = "jdbc:sqlserver://sql...";

            ResultSet resultSet = null;

            try (Connection connection = DriverManager.getConnection(connectionUrl);
                Statement statement = connection.createStatement();) {

               // Create and execute a SELECT SQL statement.
                String selectSql = "SELECT TOP 10 artist FROM [dbo].[RadioEventsTarget]";
                resultSet = statement.executeQuery(selectSql);

                // Print results from select statement
                while (resultSet.next()) {
                System.out.println(resultSet.getString(2) + " " + resultSet.getString(3));
                }
       }
            // Handle any errors that may have occurred.
            catch (SQLException e) {
            e.printStackTrace();
            }

    //context.getLogger().info(message);
}

}

朱东ny:

我需要使用VS Code处理驱动程序问题吗?

您需要将jdbc驱动程序依赖项添加到pom.xml文件中。这是我用来连接到Azure SQL的依赖项示例。

    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>8.2.2.jre8</version>
    </dependency>

参考:

https://docs.microsoft.com/zh-cn/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

java.sql.SQLException:找不到适合jdbc:hive:// localhost:10000 / default的驱动程序

Java如何找到新的JDBC驱动程序?

java.sql.SQLException:找不到适用于jdbc:microsoft:sqlserver的驱动程序

如何解决java.sql.SQLException:找不到适用于jdbc:derby的驱动程序:

java.sql.SQLException:找不到适用于jdbc:mysql:// localhost:3306 / database的驱动程序

Tomcat 8-java.sql.SQLException:无法为连接URL'jdbc:mysql:// xxx / myApp'创建类''的JDBC驱动程序

为什么我的代码不断获取java.sql.SQLException:[Microsoft] [ODBC Driver Manager]数据源名称未找到且未指定默认驱动程序?

嵌套异常是java.sql.SQLException:无法为连接URL'null'创建类''的JDBC驱动程序-Spring MVC JNDI问题

春季战争文件“ java.sql.SQLException:找不到适用于jdbc:postgresql的驱动程序:”

Scala错误:java.sql.SQLException:找不到适用于jdbc:calcite的驱动程序:

找不到合适的驱动程序(Postgres JDBC):java.sql.SQLException:找不到适用于jdbc:postgresql:// rds-service:5432 / postgres的驱动程序

java.sql.SQLException:创建Web应用程序时(POSTGRES)未找到适合“ MY AWS DATABASE”的驱动程序

java.sql.SQLException:找不到适用于jdbc:mysql:// localhost:3306 / mydatabase Android Studio Java MySQL的驱动程序

java数据库连接最终以db:java.sql.SQLException:未找到合适的驱动程序

未找到Mongodb Java驱动程序游标异常

javax.servlet.jsp.JspException:无法建立连接,DataSource无效:“ java.sql.SQLException:未找到合适的驱动程序”

java.sql.SQLException:找不到适用于jdbc:sqlite的驱动程序

如何解决异常java.sql.SQLException:没有找到合适的驱动程序?

Java + Jersey + Gradle-java.sql.SQLException:找不到合适的驱动程序

我正面临java.sql.SQLException:找不到适合jdbc:ucanaccess:// C:/的驱动程序

spark和aws redshift:java.sql.SQLException:找不到适用于jdbc的驱动程序:redshift://xxx.us-west-2.redshift.amazonaws.com:5439

java.sql.SQLException:找不到适合的驱动程序

java.sql.SQLException: 找不到适合 jdbc:mysql://localhost/WORLD 的驱动程序

java.sql.SQLException: 找不到合适的驱动程序 (SQL Server Express)

尽管有驱动程序,但 Java 编译器显示“java.sql.SQLException:找不到适合 jdbc::mysql://localhost:3306/test 的驱动程序”

JavaFX、Maven - java.sql.SQLException:找不到适合 jdbc:derby:sampleDB;create=true 的驱动程序

Groovy java.sql.SQLException:找不到适合 jdbc:sqlserver:// 的驱动程序

已解决与 SQL Server 的连接:java.sql.SQLException:找不到适合 jdbc:sqlserver 的驱动程序

java.sql.SQLException:找不到适合 jdbc://localhost:3306/twitch 的驱动程序