Azure sql database java.sql.SQLException:连接到azure数据库时未找到适合jdbc:sqlserver的驱动程序

Azure sql database java.sql.SQLException:连接到azure数据库时未找到适合jdbc:sqlserver的驱动程序,azure-sql-database,sqlexception,Azure Sql Database,Sqlexception,我正在使用azure数据库,并将所有必需的JAR文件添加到我的库中。这是我的代码,我不知道为什么它无法连接。请告知 String connectionUrl = "jdbc:sqlserver://bcs430-final-project.database.windows.net:1433;" + "database=OASIS ASSISTANT;" + "user

我正在使用azure数据库,并将所有必需的JAR文件添加到我的库中。这是我的代码,我不知道为什么它无法连接。请告知

 String connectionUrl =
                "jdbc:sqlserver://bcs430-final-project.database.windows.net:1433;"
                        + "database=OASIS ASSISTANT;"
                        + "user=farmingdale@bcs430-final-project;"
                        + "password=bcs430w!;"
                        + "encrypt=true;"
                        + "trustServerCertificate=false;"
                        + "loginTimeout=30;";




     String insertSql = "select * from dbo.BCS102 where crse = bcs102 ";

        ResultSet resultSet = null;

        try (Connection connection = DriverManager.getConnection(connectionUrl);
                PreparedStatement prepsInsertProduct = connection.prepareStatement(insertSql, Statement.RETURN_GENERATED_KEYS);) {

            prepsInsertProduct.execute();
            // Retrieve the generated key from the insert.
            resultSet = prepsInsertProduct.getGeneratedKeys();

            // Print the ID of the inserted row.
            while (resultSet.next()) {
                System.out.println("Generated: " + resultSet.getString(1));
            }
        }
        // Handle any errors that may have occurred.
        catch (Exception e) {
            e.printStackTrace();
        }
这里是错误

java.sql.SQLException: No suitable driver found for jdbc:sqlserver://bcs430-final-project.database.windows.net:1433;database=OASIS ASSISTANT;user=farmingdale@bcs430-final-project;password=bcs430w!;encrypt=true;trustServerCertificate=false;loginTimeout=30;
    at java.sql.DriverManager.getConnection(DriverManager.java:689)
    at java.sql.DriverManager.getConnection(DriverManager.java:270)
    at SeniorProject.main(SeniorProject.java:35)

错误表明您没有安装适合JDBC的驱动器

请检查是否已添加依赖项。使用以下代码将MicrosoftJDBC驱动程序for SQL Server添加到项目的依赖项中

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>7.0.0.jre8</version>
</dependency>
您可以在门户网站上获取广告连接字符串:


希望这有帮助。

您好,如果我的答案对您有帮助,您可以将其作为答案接受(单击答案旁边的复选标记,将其从灰色切换为填充)。这可能对其他社区成员有益。非常感谢。
jdbc:sqlserver://***.database.windows.net:1433;database=Mydatabase;user={your_username_here};password={your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;authentication=ActiveDirectoryPassword