数据库重新启动后将 jdbc 数据源重新连接到 sybase ASE 12.5

发布于 2024-12-18 17:54:48 字数 2014 浏览 3 评论 0原文

我有一个使用 jtds 驱动程序和 commons-dbcp 作为连接池的 java 应用程序。此应用程序连接到 Sybase ASE 12.5sybase 有时会重新启动以进行维护。重新启动后,我的应用程序尝试重新连接到 sybase,但它似乎总是失败,并出现以下异常:

java.sql.SQLException: Stored procedure 'dbo.pmxSystemDate' not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output). at 
    net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368) at 
    net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820) at 
    net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258) at 
    net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632) at 
    net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477) at 
    net.sourceforge.jtds.jdbc.JtdsStatement.executeQuery(JtdsStatement.java:1304) 

这是数据源的 spring 配置:

<bean id="ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
    <property name="url" value="jdbc:jtds:sybase://dbms:6000/dbTD" />
    <property name="username" value="sa" />
    <property name="password" value="" />
    <property name="initialSize" value="5"/>
    <property name="maxActive" value="10"/>
    <property name="validationQuery" value="SELECT 1" />
    <property name="testOnBorrow" value="true" />
    <property name="maxWait" value="10" />      
    <property name="removeAbandoned" value="true" />
    <property name="removeAbandonedTimeout" value="10" />
    <property name="validationQueryTimeout" value="3" />
</bean>

如果我尝试模拟通过禁用然后启用网络接口来解决网络故障,一切都按预期工作,并且我的应用程序成功重新连接。

我也尝试过 jconnect sybase 驱动程序,但没有成功。

我知道我可以通过指定完全限定的对象名称来解决此问题,但在这种情况下,我将对源进行大量编辑,因此我正在寻找更简单的解决方案。

有人遇到过这样的问题吗?

I have a java application that uses jtds driver and commons-dbcp as a connection pool. This application connects to the Sybase ASE 12.5. From time to time sybase is restarted for the maintenance. After restart my application tries to reconnect to sybase, but it seems to fail all the time with the following exception:

java.sql.SQLException: Stored procedure 'dbo.pmxSystemDate' not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output). at 
    net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368) at 
    net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820) at 
    net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258) at 
    net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632) at 
    net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477) at 
    net.sourceforge.jtds.jdbc.JtdsStatement.executeQuery(JtdsStatement.java:1304) 

Here is spring configuration of the datasource:

<bean id="ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
    <property name="url" value="jdbc:jtds:sybase://dbms:6000/dbTD" />
    <property name="username" value="sa" />
    <property name="password" value="" />
    <property name="initialSize" value="5"/>
    <property name="maxActive" value="10"/>
    <property name="validationQuery" value="SELECT 1" />
    <property name="testOnBorrow" value="true" />
    <property name="maxWait" value="10" />      
    <property name="removeAbandoned" value="true" />
    <property name="removeAbandonedTimeout" value="10" />
    <property name="validationQueryTimeout" value="3" />
</bean>

If I try to emulate the network failure by disabling and then enabling the network interface everything works as expected and my app reconnects successfully.

I have also tried jconnect sybase driver but without success.

I understand that I can workaround this issue by means of specifying fully-qualified object names, but in that case I will have a lot of editing of my sources, so I'm looking for the simpler solution.

Have anyone faced with such an issue?

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

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

发布评论

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

评论(1

晨曦慕雪 2024-12-25 17:54:48

好吧,为了解决这个问题,我必须将验证查询从更改

select 1

select name from dbTD..sysobjects where name='sysobjects'

Well, to overcome this issue I had to change validation query from

select 1

to

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