简体   繁体   中英

Java connect to OracleDB very slowly (with ojdbc6.jar and Linux)

I'm try to deploy the web services that have a connection to ORACLE database (10g).

Currently, I have - CentOS 6.4 64bits - Apache Tomcat 7.0.42 with JDK 1.7.0_25 - Ojdbc6.jar

When I calling web services with the same version of tomcat on Windows. It's working properly (0.1-0.5 Seconds/transaction).

but unfortunately, when I try to call it on CentOS server, It quite very slow (10-20 seconds/transaction)

The libraries are exactly same except the OS and as I monitoring catalina.out, there is no error but It's slowly when dbCreateConnection() was executed)

Please give me an advise.

Thanks :\\

FYI, Here is the code in database section.

try { 
            Class.forName("oracle.jdbc.OracleDriver");

            InputStream isr = this.getClass().getResourceAsStream("/"+"dbConfig.properties");
            Properties prop = new Properties();
            if (isr != null){
              InputStreamReader isrProperties = new InputStreamReader(isr);
              prop.load(isrProperties);
            }

            String dbURL = "jdbc:oracle:thin:@"+prop.getProperty("dbhost")+":"+prop.getProperty("dbport")+":"+prop.getProperty("dbname");
            System.out.println("TRACE : getdbConfig --> "+dbURL);
            String username = prop.getProperty("dbuser");
            String password = prop.getProperty("dbpass");

            dbConn = DriverManager.getConnection(dbURL, username, password);
            if(dbConn != null){
                System.out.println("TRACE : Connected to "+dbURL);
            }
        } 
        catch (SQLException ex) {
            System.out.println("Error Message : getConnection Failed --> "+ex.getSQLState());
            ex.printStackTrace();
        } 

使用JVM标志启动Java:

-Djava.security.egd=file:/dev/./urandom

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM