Connecting to Informix through DriverManager.getConnection is slow

I am using JDBC to connect to an Informix instance through DriverManager.getConnection method, but I have problems.

DriverManager.getConnectionIt takes a long time to establish a connection with Informix. I am trying to solve this problem, but have failed so far.

How to solve this problem?

0
source share
2 answers

You can write a simple test that shows how long it takes to connect to the database. For such things, I like Jython, which can work with JDBC, which can work with native JDBC drivers, and through the JDBC-ODBC bridge, it can work with the ODBC driver. Of course, you must first set up such an ODBC connection.

, :

import sys
import traceback
import time

from java.sql import DriverManager
from java.lang import Class

Class.forName("com.informix.jdbc.IfxDriver")

def test_conn(db_url, usr, passwd):
    try:
        t0 = time.time()
        try:
            db = DriverManager.getConnection(db_url, usr, passwd)
            t2 = time.time()
            print('%s' % (db_url))
            print('%s, connection time %.03f [s]\n' % (db, (t2-t0)))
        finally:
            db.close()
    except:
        print("there were errors!")
        s = traceback.format_exc()
        sys.stderr.write("%s\n" % (s))


def main():
    for _ in range(5):
        test_conn('jdbc:informix-sqli://169.0.5.10:9088/test:informixserver=ol_t1;', 'user', 'passwd')
        test_conn('jdbc:odbc:ifx_test', 'user', 'passwd')

main()

, JDBC JDBC-ODBC ( , , ). Windows, time.time() , , ~ 15 . :

jdbc:informix-sqli://169.0.5.10...
com.informix.jdbc.IfxSqliConnect@1658cfb, connection time 0.015 [s]

jdbc:odbc:test
sun.jdbc.odbc.JdbcOdbcConnection@ad75b, connection time 0.047 [s]

, , .

+1

, hosts 127.0.0.1 localhost.

Informix IPv6 , SO:

0

All Articles