java 无法使用 JDBC 连接到 Syabse 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17230774/
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
Not able to connect to Syabse database using JDBC
提问by Umesh K
Hi I am getting problem of not connecting to sybase database using jdbc. I have also put jconn.jar in dependency of intellij 12.1.
嗨,我遇到了无法使用 jdbc 连接到 sybase 数据库的问题。我还把 jconn.jar 放在了 intellij 12.1 的依赖中。
I am getting the following excpetion
我得到以下异常
java.sql.SQLException: No suitable driver found for jdbc:jtds:sybase:some.com:8000/DBAQ02 at java.sql.DriverManager.getConnection(DriverManager.java:604) at java.sql.DriverManager.getConnection(DriverManager.java:221) at gbconnect.DBConnectPOC.main(DBConnectPOC.java:81) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
java.sql.SQLException: 在 java.sql.DriverManager.getConnection(DriverManager.java:604) 在 java.sql.DriverManager.getConnection(DriverManager.getConnection(DriverManager. java:221) at gbconnect.DBConnectPOC.main(DBConnectPOC.java:81) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl .invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Please see the following code . Please guide I am really got mad. Thanks in advance.
请参阅以下代码。请指导我真的很生气。提前致谢。
try
{
Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
}
catch (ClassNotFoundException e)
{
throw new IllegalArgumentException(
"Driver class '" + driverClassName + "' is not valid.", e);
}
}
//jdbc:jtds:sybase://some.com:8000/DBAQ02
Statement stmt = null;
Connection conn = null;
try
{
System.out.println(driverClassName + "://" + url);
conn = DriverManager.getConnection("jdbc:jtds:sybase:some.com:8000/DBAQ02","sa","abc");
stmt = conn.createStatement();
stmt.executeUpdate(SQL_CREATE);
System.out.println("Created table in given database...");
}
回答by zigzag
I know m way too late but came across this question just now. So, here are some things: Did you try: 1)jconn4.jar
我知道我太晚了,但刚刚遇到了这个问题。所以,这里有一些事情:你有没有尝试过:1)jconn4.jar
2)Class.forName("com.sybase.jdbc4.jdbc.SybDriver");
2)Class.forName("com.sybase.jdbc4.jdbc.SybDriver");
3)DriverManager.getConnection("jdbc:sybase:Tds:some.com:8000?ServiceName=DBAQ02", "sa", "abc");
3)DriverManager.getConnection("jdbc:sybase:Tds:some.com:8000?ServiceName=DBAQ02", "sa", "abc");
4)Are you sure the url is: some.com?
4)你确定网址是:some.com?
5)Instead of using some.com, why don't you put the actual IP address?
5)为什么不使用some.com,为什么不输入实际IP地址?
6)Are you sure 8000 is the port? Check it once.
6) 你确定 8000 是端口吗?检查一次。
Link source that helped: http://fm4dd.com/database/howto-install-Sybase-jdbc.htm
有帮助的链接源:http: //fm4dd.com/database/howto-install-Sybase-jdbc.htm
回答by Thihara
Please check your connection URL.
请检查您的连接 URL。
It should be jdbc:sybase:Tds:some.com:8000
for the driver you are loading.
它应该jdbc:sybase:Tds:some.com:8000
用于您正在加载的驱动程序。