Today, The following exception occurs when Tomcat connects to the Oracle database: org. apache. commons. dbcp. SQLNestedException: Cannot create PoolableConnectionFactory (Io exception: The Network Adapter cocould not establish the connection)
Specific Error
Java. SQL. SQLRecoverableException: Io exception: The Network Adapter cocould not establish the connection
At oracle. jdbc. driver. SQLStateMapping. newSQLException (SQLStateMapping. java: 101)
At oracle. jdbc. driver. DatabaseError. newSQLException (DatabaseError. java: 112)
At oracle. jdbc. driver. DatabaseError. throwSqlException (DatabaseError. java: 173)
At oracle. jdbc. driver. DatabaseError. throwSqlException (DatabaseError. java: 229)
At oracle. jdbc. driver. DatabaseError. throwSqlException (DatabaseError. java: 458)
At oracle. jdbc. driver. T4CConnection. logon (T4CConnection. java: 411)
At oracle. jdbc. driver. PhysicalConnection. <init> (PhysicalConnection. java: 490)
At oracle. jdbc. driver. T4CConnection. <init> (T4CConnection. java: 202)
At oracle. jdbc. driver. T4CDriverExtension. getConnection (T4CDriverExtension. java: 33)
At oracle. jdbc. driver. OracleDriver. connect (OracleDriver. java: 474)
At java. SQL. DriverManager. getConnection (Unknown Source)
At java. SQL. DriverManager. getConnection (Unknown Source)
At chap6.DBUtil. getConnection (DBUtil. java: 14)
At chap6.StatementDemo. main (StatementDemo. java: 15)
Java. SQL. SQLException: Driver error or connection failure!
At chap6.DBUtil. getConnection (DBUtil. java: 20)
At chap6.StatementDemo. main (StatementDemo. java: 15)
Solution 1
Later, three ports 8080,800, 8005 and were opened in the firewall. The problem was solved.
Solution 2
Oracle's thin connection is divided into two types: SID and service name. The difference between the two is how the server configures the SID or service name. After configuring the database, you can
The Code is as follows: |
Copy code |
D: oracleproduct10.2.0db _ 1 NETWORKADMIN |
Find the tnsnames. ora file in the directory and check the parameters.
Confirm the method based on the preceding data configuration.
A. in SID mode, the JDBC connection form is
The Code is as follows: |
Copy code |
String url = "jdbc: oracle: thin: @ // 192.168.10.105: 1522: uportal "; |
Note that when you connect to a data instance, use the colon:
B. For the SERVICE mode, the JDBC connection data format is
The Code is as follows: |
Copy code |
String url = "jdbc: oracle: thin: @ // 192.168.10.105: 1522/uportal "; |
Note that when you connect to a data instance, the slashes/