Java 无法使用 SQuirrelSQL 连接到 SQL 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24858072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not connect to SQL Database using SQuirrelSQL
提问by ariabele
I encounter the following error when trying to connect to a database using SQuirreLSQL.
尝试使用SQuirreLSQL连接到数据库时遇到以下错误。
Error :
错误 :
Unexpected Error occured attempting to open an SQL connection
Unexpected Error occured attempting to open an SQL connection
Stacktrace :
堆栈跟踪 :
java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:202)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.awaitConnection(OpenConnectionCommand.java:132)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access0(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.run(OpenConnectionCommand.java:115)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:175)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$HOME/squirrel-sql-3.7/lib/mysql-connector-java-3.0.17-ga-bin.jar
0(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.run(OpenConnectionCommand.java:104)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.net.URLClassLoader.run(URLClassLoader.java:366)
at java.net.URLClassLoader.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at net.sourceforge.squirrel_sql.fw.util.MyURLClassLoader.findClass(MyURLClassLoader.java:209)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:128)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:167)
... 7 more
I also tried to check Driver Properties and the following error is displayed :
我还尝试检查驱动程序属性并显示以下错误:
Loading JDBC driver "Microsoft MSSQL Server JDBC Driver
" failed.
Can not load driver properties tab.
加载 JDBC 驱动程序“ Microsoft MSSQL Server JDBC Driver
”失败。无法加载驱动程序属性选项卡。
采纳答案by Konki
You need to copy driver into squirrel-sql/lib folder. I've had same issue with MySql driver. After copied drived into:
您需要将驱动程序复制到 squirrel-sql/lib 文件夹中。我对 MySql 驱动程序有同样的问题。复制后驱动到:
##代码##and restart Squirrel - there was no error anymore.
并重新启动 Squirrel - 不再有错误。