我已经在我的系统上设置了oracle11g
数据库,其他两台机器通过JDBC
. 但由于某种原因IP address
,我的系统已更改。我无法从其他机器访问数据库,即使我已经更改了 IP 地址JDBC connection URL
,
但我仍然得到connection failure error
。Network adapter could not establish the connection
我在下面的代码中进行了更改。
public static DbConnector getConnection(String dataSourceIp, String dataSourceJndiName) throws Exception {
DbConnector con = new DbConnector();
try {
String jdbcURL = "jdbc:oracle:thin:@10.220.140.48:1521:test1";
Class.forName("oracle.jdbc.OracleDriver").newInstance();
String user = "XXXX";
String passwd = "YYYYYY";
Connection conn = DriverManager.getConnection(jdbcURL, user, passwd);
con.conn = conn;
con.conn.setAutoCommit(false);
return con;
/*DataSource ds = getDataSource(dataSourceIp, dataSourceJndiName);
con.conn = ds.getConnection();
con.conn.setAutoCommit(false);
return con;*/
} catch (Exception e) {
try {
// bu method getConnection methodudur. disconnectDB finally'ye
// tasinmamalidir.
String jdbcURL = "jdbc:oracle:thin:@10.220.140.48:1521:test1";
Class.forName("oracle.jdbc.OracleDriver").newInstance();
String user = "xxxxx";
String passwd = "yyyyyy";
Connection conn = DriverManager.getConnection(jdbcURL, user, passwd);
con.conn = conn;
con.conn.setAutoCommit(false);
return con;
/*dataSourceMap.remove(dataSourceIp + dataSourceJndiName);
DataSource ds = getDataSource(dataSourceIp, dataSourceJndiName);
con.conn = ds.getConnection();
con.conn.setAutoCommit(false);
return con;*/
} catch (Exception ex) {
con.disconnectDB();
}
throw e;
}
}
我在上面的代码中更改了 IP 地址并替换为新的 IP 地址。