嗨,我遇到了未使用 jdbc 连接到 sybase 数据库的问题。我还将 jconn.jar 置于 intellij 12.1 的依赖项中。
我收到以下异常
java.sql.SQLException:在 java.sql.DriverManager.getConnection(DriverManager.java:604) 的 java.sql.DriverManager.getConnection(DriverManager. java:221) 在 gbconnect.DBConnectPOC.main(DBConnectPOC.java:81) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 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)
请看下面的代码。请指导我真的很生气。提前致谢。
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...");
}