先看连接池配置:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${driver.class}" /> <property name="url" value="${driver.url}" /> <property name="username" value="${db.username}" /> <property name="password" value="${db.password}" /> </bean>
再看对应的配置:
driver.class=oracle.jdbc.driver.OracleDriver
driver.url=jdbc:oracle:thin:@10.40.95.152:1521:test
db.username=wlf
db.password=123456
然后启动失败了:
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
去PL/SQL试了下,发现给的用户密码是数据库服务的,而不是实例的。用service_name可以登录Oracle,但SID不行。把配置改为service_name方式连接成功
driver.class=oracle.jdbc.driver.OracleDriver
driver.url=jdbc:oracle:thin:@//10.40.95.152:1521/test
db.username=wlf
db.password=123456