找不到合适的驱动程序Snowball JDBC

问题描述 投票:1回答:1

我目前正在处理一个应用程序。我们正在从文件系统转移到Snowflake数据库。我似乎无法建立与数据库的连接-不断遇到“找不到合适的驱动程序”错误。

正确的驱动程序已加载并安装到构建路径中。 有人知道发生了什么吗?

代码:

package com.GriefUI.DBComponents;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class Snowflake_Driver {

public static void databaseConnection(HttpServletRequest request, HttpServletResponse response) throws UnsupportedOperationException{


    try {

        Connection connObject = getConnection();
        Statement stmt = connObject.createStatement();
        ResultSet rSet = stmt.executeQuery("SELECT * FROM MY_TABLE");


    }catch(Exception e) {
        e.printStackTrace();
        throw new UnsupportedOperationException();
    }

}


 private static Connection getConnection()
          throws SQLException {
        try {
          Class.forName("net.snowflake.client.jdbc.SnowflakeDriver");
        } catch (ClassNotFoundException ex) {
          System.err.println("Driver not found");
        }

        Properties properties = new Properties();

        String user = "user";
        String pwsd = "password";
        String connectStr = "jdbc:snowflake://My_Environment.snowflakecomputing.com";

        Connection conn = DriverManager.getConnection(connectStr, user, pwsd);
        return conn;
      }

 }

构建路径:

Build path

以及相关的堆栈跟踪:

Driver not found
java.sql.SQLException: No suitable driver found for jdbc:snowflake://My_Environment.snowflakecomputing.com
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.GriefUI.DBComponents.Snowflake_Driver.getConnection(Snowflake_Driver.java:54)
at com.GriefUI.DBComponents.Snowflake_Driver.databaseConnection(Snowflake_Driver.java:20)
at com.GriefUI.Servers.PushServer.doPost(PushServer.java:60)
at com.GriefUI.Servers.PushServer.doGet(PushServer.java:47)
java jdbc snowflake
1个回答
0
投票

我建议看一下的研究是:https://docs.snowflake.net/manuals/user-guide/jdbc-configure.html

此答案似乎也很有帮助:https://stackoverflow.com/a/54504514/12127815尽管此处要求使用轻型罐子作为增强功能:https://github.com/snowflakedb/snowflake-jdbc/issues/174

将驱动程序集成到项目中:https://docs.snowflake.net/manuals/user-guide/jdbc-download.html#integrating-the-driver-into-a-project

其他人可能会有更好的见解。

© www.soinside.com 2019 - 2024. All rights reserved.