在切换数据库德时候由于原来的配置是jdbc.url=jdbc:oracle:thin:@10.0.0.28:1526:ORCL ,要切换刀106数据库,于是改成
jdbc.url=jdbc:oracle:thin:@10.0.0.106:1526:ORCL 报下列异常
网上搜索出3种情况出现上述错误
1、IP错误:
在设置URL时错误,例如:jdbc:oracle:thin:@192.168.1.80:1521:orcl
数据库服务器是否正确:ping 服务器IP是否通畅。ping不通则将URL更改正确。
端口号是否正确。
进行一下操作:在DOS上键入sqlplus,检查oracle是否开启
一切正常则执行下面第2步。
2、防火墙
如果机器上安装有放火墙,可能是服务器端口号屏蔽而造成的。关闭防火墙后,尝试重新连接。
仍然不行则执行第3步。
3.l没有配置监听器
查看防火墙 window7环境 开始——控制面板——网络和internet连接——防火墙 发现防火墙式关闭的
查看监听器 slqplus客户端工具 条help(帮助)——Support info... 找到TNS File
TNS File
D:\oracle10g\instantclient_10_2\tnsnames.ora
打开 txt打开 D:\oracle10g\instantclient_10_2\tnsnames.ora
xiu2.0=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.106)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = WCSDB)
)
)
发现106是配置的IP配置错误!把
jdbc.url=jdbc:oracle:thin:@10.0.0.28:1526:ORCL 改成
jdbc.url=jdbc:oracle:thin:@192.168.3.106:1526:ORCL 测试还是原来那个错误!
再把地址对比一下ORCL 与WCSDB不一样,监听器里面配了名字把ORCL改成WCSDB
错误还在,额的个郁闷 由于从别人那里拷贝个监听配置端口不对,1526改成1521再试成功!ip,端口,数据库都犯了错误,郁闷,不知道在想什么
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:577)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:641)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:682)
at com.xiu.search.good.GoodSearchIndexHelper.getSingleBatchGoodIDs(GoodSearchIndexHelper.java:438)
at com.xiu.search.good.GoodSearchIndexHelper.getGoodIDs(GoodSearchIndexHelper.java:399)
at com.xiu.search.good.integration.MultipleGoodsPriceChangedMessageHandlerImpl.onMessage(MultipleGoodsPriceChangedMessageHandlerImpl.java:76)
at com.xiu.search.jms.PriceMessageListener.onMessage(PriceMessageListener.java:40)
at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1230)
at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:134)
at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:205)
at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:127)
at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:297)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:221)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:165)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
... 16 more