Friday, November 2, 2007

Io exception: The Network Adapter could not establish the connection

Recently, i did an RAC validation with our oracle partner and encountered this weird exception called "Io exception: The Network Adapter could not establish the connection".

Two client machine were running same java code (using jdbc thin driver & oracle datasource) in the same LAN as RAC servers, but they came out with differen behaviour. One could connect to RAC database, the other one always got io exception mentioned above.

The only difference between two machines was one of clients' host file having rac ip & hostname mapping entry, which is able to connect to oracle rac db.

Something weird is that all db clients and servers were actually sitting in the same LAN. I could ping and telnet db rac with rac ip address (virtual and real ) from client machines, but when i use ip address in the java class to lookup the db connection, i could not get connected to db if rac ip & hostname mapping entries were not available in the client host file.

Here is the sample Codes for RAC FCF connection:

OracleDataSource ods = new OracleDataSource();
OracleConnectionCacheManager occm = null;
String cacheName = "cache";
String dbURL="jdbc:oracle:thin:@"+
"(HOST=rac1-vip-address)(PORT=1521))" +
"(HOST=rac2-vip-address)(PORT=1521)))" +
ods.setURL(dbURL); System.out.println("Url=" + dbURL ); ods.setConnectionCachingEnabled(true);
Properties prop = new Properties();
prop.setProperty("MinLimit", "5");
prop.setProperty("MaxLimit", "40");
prop.setProperty("InitialLimit", "10");
prop.put (,"" + (5000)); // 5000ms ods.setConnectionCacheProperties(prop);
ods.setONSConfiguration("nodes=rac1-ip-address:6200,rac2-ip-address:6200"); ods.setConnectionCacheName(cacheName);
//occm = OracleConnectionCacheManager.getConnectionCacheManagerInstance();
Connection conn = ods.getConnection();

It looks somewhere JDBC driver looking up db connection with rac hostname instead of ip address and I have to put the rac ip & hostname mapping in the client host file for jdbc driver to resolve them.


Anonymous said...

amazing stuff thanx :)

Anonymous said...

i really love your own posting taste, very unique.
don't give up and also keep writing in all honesty , because it simply just truly worth to look through it.
looking forward to look over additional of your current article content, enjoy your day ;)