java.sql.SQLException:sun.jdbc.odbc.JdbcOdbc.createSQLException 处的一般错误(来源未知)
我正在尝试使用以下例程建立 JDBC-ODBC 连接,
private static Connection getConnection(String systemDSN, String username, String password) throws Exception {
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:" + systemDSN;
Class.forName(driver);
return DriverManager.getConnection(url, username, password);
}
这是我得到的完整堆栈跟踪!
java.sql.SQLException: General error at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
谁能告诉我这是怎么造成的以及我该如何补救??!
I'm trying to establish a JDBC-ODBC connection using the following routine,
private static Connection getConnection(String systemDSN, String username, String password) throws Exception {
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:" + systemDSN;
Class.forName(driver);
return DriverManager.getConnection(url, username, password);
}
And here's the complete stack trace I'm getting!
java.sql.SQLException: General error at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
Can anyone PLEASE let me know how this is caused and how I can remedy this??!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
想知道这是否可能是另一个位数问题?
如果这是 64 位系统,那么 Java 运行时的位数很重要!!!!
64 位 Java 运行时将只能访问 64 位 ODBC 驱动程序...
32 位 Java 运行时将只能访问 32 位 ODBC 驱动程序...
32 位和 64 位 ODBC 环境不一样...
Wondering if this could be yet another bitness issue?
If this is a 64bit system then the bitness of the Java runtime is important!!!!
64bit Java run time will only be able to access 64bit ODBC drivers...
32bit Java run time will only be able to access 32bit ODBC drivers...
32bit and 64bit ODBC environments are not the same...
寻找“一般错误”的答案我终于发现是数据源名称上的问题。
jdbc:odbc:xx
其中xx
是数据源名称而不是数据库名称它对我有用!
Looking for the answer for "general error" I finally found that it is the problem on the data source name.
jdbc:odbc:xx
wherexx
is the data source name NOT the data base nameIt works form me!