On Spring startup, I'm getting the SQLException "Io exception: The Network Adapter could not establish the connection" thrown from the Oracle driver. I am running Oracle 9.2.0.5.
I am able to establish a connection normally using plain JDBC and even Apache DBCP BasicDatasource. Using my colleague's PC, I can connect with Hibernate outside of Spring as well.
Steps I have tried are to use spring's driver manager data source, apache dbcp's data source and even hibernate's own built-in data source, all resulting in the same error. What could be causing the error?
Below is my applicationContext-hibernate.xml and the stack trace.
applicationContext-hibernate.xml:
Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property> <property name="url"><value>jdbc:oracle:thin:@l55.161.154.154:1521:tst</value></property> <property name="username"><value>myuser</value></property> <property name="password"><value>mypassword</value></property> </bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="mappingDirectoryLocations"> <list> <value>src/classes</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop> <prop key="hibernate.query.substitutions">true=1 false=0</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="dataSource"><ref bean="myDataSource"/></property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"><ref local="mySessionFactory"/></property> </bean> <bean id="userDao" class="com.fedex.tmsc.dao.persistence.hibernate.UserDaoImpl"> <property name="sessionFactory"> <ref bean="mySessionFactory"/> </property> </bean> </beans>
Stack trace:
Code:WARNING: Error while getting database metadata org.springframework.jdbc.support.MetaDataAccessException: Error while getting connection; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is java.sql.SQLException: Io exception: The Network Adapter could not establish the connection org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is java.sql.SQLException: Io exception: The Network Adapter could not establish the connection java.sql.SQLException: Io exception: The Network Adapter could not establish the connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:158) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:382) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:333) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:371) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:148) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:572) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:156) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:144) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:132) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:173) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:152) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:128) at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:93)


Reply With Quote