1
尝试连接到设置为只读的数据库时,无法建立连接。我得到以下错误:连接到只读数据库
Cannot create PoolableConnectionFactory (Io exception: The Network Adapter could not
establish the connection)
应用程序需要在读写模式下运行,然后自动处理切换到只读只检查连接对象的IsReadOnly属性。应用程序在连接到读写数据库时正常运行,但在更改为下面的连接字符串时(删除安全信息)失败。我已经验证连接字符串是正确的,所以问题不在于此。
ca.businesssolutions.nbs.jdbc.connect=jdbc:oracle:thin:unicorn_read_only/[email protected](DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=9999)))(CONNECT_DATA=(SID=SBSBTST)(SERVER=DEDICATED)))
我很难找出从哪里开始寻找。我继承了该应用程序,并不确定它是否是弹簧框架限制或我错过的其他设置。
的数据源Spring的配置是:
<bean id="dataSource" class="ca.businesssolutions.nbs.server.base.datasource.MyBasicDataSource"
destroy-method="close">
<!--url and driver class name are set through Configuratoin object.-->
<property name="initialSize" value="10"/>
<property name="maxActive" value="-1"/>
<property name="validationQuery" value="SELECT 1 FROM DUAL"/>
<property name="accessToUnderlyingConnectionAllowed" value="true"/>
</bean>
数据源的构造函数:
public MyBasicDataSource() {
super();
setUrl(Configuration.get(Configuration.CONNECT));
setDriverClassName(Configuration.get(Configuration.DRIVER_NAME));
//The initial number of connections that are created when the pool is started.
int numConnections = 10;
try {
numConnections = Integer.parseInt(Configuration.get(Configuration.NUMBER_OF_CONNECTIONS));
} catch (Exception exception) {
// Do nothing.
}
setInitialSize(numConnections);
//The maximum number of active connections that can be allocated from this pool at the same time, or non-positive for no limit.
setMaxActive(-1);
setValidationQuery("SELECT 1 FROM DUAL");
setAccessToUnderlyingConnectionAllowed(true);
DataAccessObject.setDataSource(this);
}
还有什么可以帮助?
谢谢。我发现了这个错字。这是一个无法解析的主机名。 – jgreep 2009-01-23 22:41:54