java.sql.SQLException:sun.jdbc.odbc.JdbcOdbc.createSQLException 处的一般错误(来源未知)

发布于 2024-12-11 19:46:43 字数 884 浏览 0 评论 0原文

我正在尝试使用以下例程建立 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木格 2024-12-18 19:46:43

想知道这是否可能是另一个位数问题?

如果这是 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...

小…红帽 2024-12-18 19:46:43

寻找“一般错误”的答案我终于发现是数据源名称上的问题。

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 where xx is the data source name NOT the data base name

It works form me!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文