GlassFish 到 MS Access 的连接池

发布于 2024-12-20 03:30:55 字数 1341 浏览 2 评论 0原文

由于我的罪孽,我必须使我正在处理的 Web 应用程序与我们的遗留应用程序之一使用的旧 MS Access 数据库进行交互。

Access 的第一个问题当然是如何获得连接。经过大量搜索后,我找不到任何令我满意的类型 3 或 4 驱动程序(每个销售它们的人似乎几年前就停止了开发),因此这迫使我使用 JDBC-ODBC 桥。

由于我已经十多年没有使用过这座桥了,所以我快速编写了一些代码来检查一切是否正常:

sun.jdbc.odbc.ee.DataSource ds = new sun.jdbc.odbc.ee.DataSource();
ds.setDatabaseName("MyDatabase");
Connection conn = ds.getConnection();
PreparedStatement stmt = conn.prepareStatement( "SELECT * FROM MyTable" );
ResultSet rs = stmt.executeQuery();
while( rs.next() ) {
    System.out.println( rs.getString( 1 ) );
}

我决定使用 DataSource 因为这更接近它的使用方式在最终的应用程序中。上面的代码运行良好并给出了预期的结果。

然后我在 GlassFish 3.1.1 下设置了一个 JDBC 连接池。我将资源类型设置为 javax.sql.DataSource,并将数据源类名指定为 sun.jdbc.odbc.ee.DataSource。我还设置了一个属性:databaseName=MyDatabase。

当我通过 GlassFish ping 数据库时,我收到此错误消息:

Ping Connection Pool for MyConnectionPool is Failed. Ping failed 
Exception - Connection could not be allocated because: 
[Microsoft][ODBC Microsoft Access Driver] System resource exceeded.

GlassFish 的 system.log 并没有真正提供任何更多信息,它只是报告:

Exception while creating an unpooled [test] connection for pool [ MyConnectionPool ]

然后重复该错误消息。我尝试更改 GlassFish 中的池参数,认为这可能是尝试池化连接数的问题,但这不起作用。有什么想法吗?

PS 目前还没有迁移到 MS SQL/MySQL/其他数据库的选项:-)

For my sins I have to make the web application I'm working on interact with an old MS Access database that is used by one of our legacy applications.

The first problem with Access of course is how to get a connection. After extensive searching I wasn't able to find any type 3 or 4 driver that I was happy with (everyone that sells them seems to have stopped development years ago) so that has pushed me into using the JDBC-ODBC bridge.

As I've not used the bridge for over a decade I banged out a quick bit of code to check everything was working:

sun.jdbc.odbc.ee.DataSource ds = new sun.jdbc.odbc.ee.DataSource();
ds.setDatabaseName("MyDatabase");
Connection conn = ds.getConnection();
PreparedStatement stmt = conn.prepareStatement( "SELECT * FROM MyTable" );
ResultSet rs = stmt.executeQuery();
while( rs.next() ) {
    System.out.println( rs.getString( 1 ) );
}

I decided to use the DataSource as this is closer to how it'll be used in the final application. The above code runs fine and gives the expected result.

I then set up a JDBC Connection Pool under GlassFish 3.1.1. I set Resource Type to javax.sql.DataSource and gave the Datasource Classname as sun.jdbc.odbc.ee.DataSource. I also set a single property of databaseName=MyDatabase.

When I ping the database through GlassFish I get this error message:

Ping Connection Pool for MyConnectionPool is Failed. Ping failed 
Exception - Connection could not be allocated because: 
[Microsoft][ODBC Microsoft Access Driver] System resource exceeded.

The system.log for GlassFish doesn't really provide any more information it just reports:

Exception while creating an unpooled [test] connection for pool [ MyConnectionPool ]

and then repeats the error message. I've tried changing the pool parameters in GlassFish thinking that it might be an issue with how many connections it's trying to pool but that didn't work. Any ideas?

P.S. Moving to MS SQL / MySQL / Other DB is not currently and option :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

暗地喜欢 2024-12-27 03:30:55

不知道到底出了什么问题,关闭更改时的自动 ping 并重新启动系统导致它开始工作,从那以后我没有遇到任何问题。

No idea what was actually wrong, turning off auto-ping on changes and restarting the system caused it to start working and I've not had any problems since.

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