gpt4 book ai didi

java - JMS 112 使用 spring ds 的连接无效

转载 作者:太空宇宙 更新时间:2023-11-04 14:07:09 24 4
gpt4 key购买 nike

我使用的是 Spring 数据源,无法连接到 Oracle AQ 队列。

Connection connection = null;
AQSession aqSess = null;

connection = ds.getConnection();
connection.setAutoCommit(false);

DataSourceUtils.getTargetConnection(connection);
Class.forName("oracle.AQ.AQOracleDriver");

aqSess = AQDriverManager.createAQSession(connection);
aqSession = aqSess;

但仍然得到这个:oracle.jms.AQjmsException:JMS-112:连接无效任何提示将不胜感激。

<bean id="myId" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@myIpAddress:dev"/>
<property name="username" value="user"/>
<property name="password" value="pass"/>
<property name="removeAbandoned" value="true"/>
<property name="initialSize" value="2"/>
<property name="maxIdle" value="8"/>
<property name="maxActive" value="30"/>
<property name="maxWait" value="60000"/>
</bean>


AQException: oracle.AQ.AQException: JMS-112: Connection is invalid
at oracle.AQ.AQDriverManager.createAQSession(AQDriverManager.java:193)

最佳答案

我使用以下代码解决了我的问题:

OracleConnection oracleConnection = connection.unwrap(OracleConnection.class);

将其记录在这里作为答案,以防其他人在遇到类似问题时发现此问题。

关于java - JMS 112 使用 spring ds 的连接无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28742128/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com