user1402674
user1402674

Reputation: 31

Does Oracle 11gR2 actually support IPV6?

Oracle has declared that 11g R2 has support IPV6 and ojdbc6.jar is the right one.

But when I test it, I get exception, have you solved that?

My test code is:

import java.sql.SQLException;
import java.util.Properties;

public class Test {

final static String sDBDriver = "oracle.jdbc.driver.OracleDriver";

/**
* @param args
* @throws SQLException 
*/

public static void main(String[] args) throws SQLException {

// TODO Auto-generated method stub
java.sql.Connection conn=null; 

String url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=
[fe80::b056:5cff:fe78:b672])(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=fnstdb1))";

try
{
Class.forName(sDBDriver);
conn = DriverManager.getConnection(url,"scott","fnst1234");
}
catch (Exception e) 
{
System.out.println("ERROR:"+e.getMessage()); 
} 
finally
{
System.out.println("连接是否关闭:"+conn.isClosed());
conn.close();
}
}

}

and I use the following cmd:

java -cp ojdbc6.jar -Djava.net.preferIPv6Addresses=true Test

but the result is: ERROR:NL Exception was generated

What is wrong?

Upvotes: 2

Views: 2508

Answers (1)

user1402674
user1402674

Reputation: 31

I have solved this problem .the following shows what have I done:

Procedure

  1. edit $DB_HOME\NETWORK\ADMIN\listener.ora file to allow the oracle to listen on the ip and port. for example: (ADDRESS = (PROTOCOL = TCP)(HOST = [fe80::221:97ff:fe66:1fa9%4])(PORT= 1521))

  2. Reatart the listener. Run: LSNRCTL stop/start

  3. In some applications (javase, connection-pool, lookup)use ojdbc6.jar: jdbc:oracle:thin:@[fe80::221:97ff:fe66:1fa9]:1521:orcl.

  4. The result is successful!!

Demo

  1. the ip address in listener.ora must add "%4" ,or it will fail.

  2. ipv6 address must in "["and "]",or it will fail.

  3. the document of oracle declares that using ipv6 must set the jvm options

    java.net.preferIPv6Addresses=true

but it does not matter whether it sets or not!

Upvotes: 1

Related Questions