我目前正在尝试与我们的Snowflake数据库建立简单连接。我遵循了他们网站上的文档:https://docs.snowflake.net/manuals/user-guide/jdbc-configure.html 并验证连接字符串正确。
每次我启动程序时,都会收到一个SQLException消息,指出它找不到jar或找不到驱动程序:
unstack
我将Maven用于依赖项。在我的POM中,我只是拥有:
s = dftest.weirdjson.explode()
df_new = (pd.DataFrame({'type': s.str['type'], 'time': s.str['time']})
.set_index('type', append=True).time.unstack().add_prefix('time_type_'))
Out[461]:
type time_type_one time_type_two
0 2019 2018
1 2013 2012
即使声明了Maven依赖关系(根据Snowflake的文档),我仍然遇到了no driver exception。然后,我将jar添加到构建路径中,并希望(也许)在构建路径上既需要maven依赖关系,又需要实际的.jar文件。这不能解决问题。
这时我很茫然。我不知道自己在做什么错,也不知道如何解决。
我的连接类:
[19:28:54] [Server thread/WARN]: driver not found
[19:28:54] [Server thread/WARN]: java.sql.SQLException: No suitable driver found for jdbc:snowflake://d9022.east-us-2.azure.snowflakecomputing.com/
[19:28:54] [Server thread/WARN]: at java.sql.DriverManager.getConnection(Unknown Source)
[19:28:54] [Server thread/WARN]: at java.sql.DriverManager.getConnection(Unknown Source)
[19:28:54] [Server thread/WARN]: at com.mcnations.nationsatwar.jdbc.DatabaseManager.getConnection(DatabaseManager.java:44)
[19:28:54] [Server thread/WARN]: at com.mcnations.nationsatwar.jdbc.DatabaseManager.init(DatabaseManager.java:50)
[19:28:54] [Server thread/WARN]: at com.mcnations.nationsatwar.jdbc.DatabaseManager.<init>(DatabaseManager.java:19)
[19:28:54] [Server thread/WARN]: at net.mcnations.nationsatwar.Player.NationPlayer.<init>(NationPlayer.java:54)
[19:28:54] [Server thread/WARN]: at net.mcnations.nationsatwar.NationsInitializer.playerLogin(NationsInitializer.java:78)
答案 0 :(得分:1)
据我了解,您没有在应用程序中部署所需的JAR(snowflake-jdbc-3.9.2.jar),因此无法在类路径中找到驱动程序。当我尝试在没有正确的类路径的情况下运行应用程序时,输出类似的结果:
java -cp snowflaketest01-1.0-SNAPSHOT.jar com.gokhanatil.snowflaketest01.Main
driver not found
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:snowflake://xxxxxxxxxx.snowflakecomputing.com/
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:189)
at com.gokhanatil.snowflaketest01.Main.getConnection(Main.java:28)
at com.gokhanatil.snowflaketest01.Main.main(Main.java:36)
您可以自己添加JAR,也可以让Maven将所需的JAR打包到最终的jar中。您可以在pom文件中添加以下内容:
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
...
因此它会产生一个大的JAR文件,其中包含所有必需的JAR(雪花驱动程序等):
java -cp snowflaketest01-1.0-SNAPSHOT-jar-with-dependencies.jar com.gokhanatil.snowflaketest01.Main
请检查Java类路径:https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html
并在使用Maven的JAR中包括依赖项: Including dependencies in a jar with Maven
答案 1 :(得分:0)
当您尝试使用Java程序连接Snowflake数据库时,发生错误“ java.sql.SQLException:找不到适用于java.sql.SQLException的驱动程序:找不到适用于jdbc:snowflake://.snowflakecommputing.com的驱动程序”但是您要么没有Snowflake JDBC驱动程序{ex。在调用getConnection()方法之前,未在类路径或驱动程序中注册雪花-jdbc-3.11.0.jar}。
请确保您已将Snowflake JDBC驱动程序“ snowflake-jdbc-3.11.0.jar”包含在Build库路径中。
答案 2 :(得分:0)
此错误是由应用程序无法找到Snowflake jdbc驱动程序引起的。当jar文件具有必需的参数(即config.yml)时,可能会发生这种情况。
因为Snowflake JDBC驱动程序没有这些必需的文件,所以我告诉主类通过以下方式同时启动自身和Snowflake JDBC jar文件:
@echo off
title Server Console
java -classpath "spigot-1.15.1.jar;lib/*" org.bukkit.craftbukkit.Main
PAUSE
第java -classpath "spigot-1.15.1.jar;lib/*" org.bukkit.craftbukkit.Main
行
状态
这些实际上是“传递”给应用程序的命令行参数。
答案 3 :(得分:-1)
I am using Eclipse and i never faced any such issue .
Create a Maven Project , put dependencies and you are good .
File->New->Project->Maven Project .Give a name to the project ->Finish .
Now add the below dependency.
<dependency>
<groupId>net.snowflake</groupId>
<artifactId>snowflake-jdbc</artifactId>
<version>3.9.0</version>
</dependency>
答案 4 :(得分:-1)
I am using Eclipse and i never faced any such issue .
Create a Maven Project , put dependencies and you are good .
File->New->Project->Maven Project .Give a name to the project ->Finish .
Now add the below dependency.
<dependency>
<groupId>net.snowflake</groupId>
<artifactId>snowflake-jdbc</artifactId>
<version>3.9.0</version>
</dependency>
是否可以获取〜/ .m2文件夹?