Here is the Java test code I wrote. It takes about 40 seconds to connect to the Oracle database using JDBC, but similar code in C# using the OracleConnection.Open method completes in less than 1 second. Does anyone know what might be causing this difference?
LocalDateTime startTime=LocalDateTime.now();
//Class.forName("oracle.jdbc.driver.OracleDriver");
String connectionUrl="jdbc:oracle:thin:@//192.168.1.100:1521/ORCL";
DriverManager.getConnection(connectionUrl, "TEST_USER", "******");
//java.util.Properties properties = new Properties();
//properties.put("user","TEST_USER");
//properties.put("password","******");
//new oracle.jdbc.OracleDriver().connect(connectionUrl, properties);
LocalDateTime endTime=LocalDateTime.now();
System.out.println("elapsed time:"+ Duration.between(startTime, endTime).getSeconds()+"seconds");
The JDBC library I'm using is ojdbc8, version 23.26.0.0.0. I also switched to the latest version of ojdbc14 for testing, and the result was the same.
The Java version is JDK 1.8, and the Oracle database version is 11g.
//in the JDBC URL? Do things improve if you remove it?Class.forNameis no longer needed (assuming the driver is on the initial classpath), it doesn't hurt either (and can help with identifying classpath or other classloading issues).@//192.168.1.100:1521/ORCLidentifies the service ORCL, while@192.168.1.100:1521/ORCLwould be invalid (or at least, should be AFAIK); there is an@192.168.1.100:1521:ORCL, but thenORCLwould be an SID, not a service name.