Informix jdbc connection

I am trying to connect to an Informix database server using jdbc using the standard method:

connection = DriverManager.getConnection("jdbc:informix-sqli://"+ip+
/"+sid+":INFORMIXSERVER="+server+";user="+user+";password="+pass+"");

But he continues to try to connect and does not give an error message (I suppose he is trying to connect because he is not showing anything). I am using the IBM Informix driver 4.10.00.1534 and Java 1.7. I use this method to connect to Informix servers so far, in fact it only fails with a single server. I can connect to this server using Informix clients with odbc, but it continues to work with jdbc without an error message.

Is there any way to add jdbc connection? Any suggestion on why this fails?

UPDATE: sqlidebug trace:

C->S (4)            
    SQ_VERSION
    SQ_EOT

S->C (14)           
    SQ_VERSION
        "7.31.TD6" [8]
    SQ_EOT

C->S (66)           
    SQ_INFO
        INFO_ENV
            Name Length = 12
            Value Length = 8
            "DBTIME"="%d/%M/%Y"
            "DBTEMP"="/tmp"
            "SUBQCACHESZ"="10"
        INFO_DONE
    SQ_EOT

S->C (2)            
    SQ_EOT

C->S (16)           
    SQ_DBOPEN
         "database" [8]
        NOT EXCLUSIVE
    SQ_EOT

S->C (28)           
    SQ_DONE
        Warning..: 0x15
        # rows...: 0
        rowid....: 0
    serial id: 0
SQ_COST
    estimated #rows: 1
    estimated I/O..: 1
SQ_EOT

C->S (78)           
    SQ_PREPARE
        # values: 0
        CMD.....: "select site from informix.systables where tabname = '   GL_COLLATE'" [65]
    SQ_NDESCRIBE
    SQ_WANTDONE
    SQ_EOT

And jdbctrace.log says:

 trying com.informix.jdbc.IfxDriver
    SQLWarning: reason(Database selected) SQLState(01I04)
    SQLWarning: reason(Float to decimal conversion has been used) SQLState(01I05)
    SQLWarning: reason(Database has transactions) SQLState(01I01)
    SQLWarning: reason(Database selected) SQLState(01I04)
    SQLWarning: reason(Database has transactions) SQLState(01I01)
    SQLWarning: reason(Database selected) SQLState(01I04)
+1
source share
6

, Informix, . JDBC, Informix. URL- , . , :

import java.io.FileWriter;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

class informix_trace
    {
    public static void main(String[] args)
        {
        try
            {
            Class.forName("com.informix.jdbc.IfxDriver");
            FileWriter fwTrace = new FileWriter("c:\\JDBCTrace.log");
            PrintWriter pwTrace = new PrintWriter(fwTrace);
            DriverManager.setLogWriter(pwTrace);
            String debug_url = "SQLIDEBUG=C:\\sqlidebug.trace";
            String url = "jdbc:informix-sqli://1.2.3.4:9088/test_db:informixserver=ol_testifx;DB_LOCALE=pl_PL.CP1250;CLIENT_LOCALE=pl_PL.CP1250;charSet=CP1250;" + debug_url
            Connection connection = DriverManager.getConnection(url, "user", "passwd");
            Statement statement = connection.createStatement();
            ResultSet resultSet = statement.executeQuery("SELECT FIRST 1 DBINFO('version','full') FROM systables;");
            while (resultSet.next())
                System.out.println(resultSet.getObject(1));
            }
        catch (Exception e)
            {
            e.printStackTrace();
            }
        }

    } // class informix_trace

Informix ( ), - sqlidebug.trace1391758523500.0. , sqliprt.

:

c:\>sqliprt  sqlidebug.trace1391758523500.0
SQLIDBG Version 1
    ...
S->C (12)
                SQ_ERR
                                SQL error..........: -329
                                ISAM/RSAM error....: -111
                                Offset in statement: 0
                                Error message......: "" [0]
                SQ_EOT

JDBCTrace.log ( ):

SQLState(IX000) vendor code(-111)
java.sql.SQLException: ISAM error: no record found.
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:413)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3412)
    at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2324)
    ....
    at java.sql.DriverManager.getConnection(Unknown Source)
    at informix_trace.main(informix_trace.java:20)
getConnection failed: java.sql.SQLException: No database found or wrong system privileges.

( , )

0

:

  • ConnectString , , ip IP-
  • ConnectString 3 getConnection(), :

    getConnection("jdbc:informix-sqli://169.0.5.10:9088/test_db:informixserver=ol_test;DB_LOCALE=pl_PL.CP1250;CLIENT_LOCALE=pl_PL.CP1250;charSet=CP1250", username, password)
    

(, )

, Wireshark. IP- Informix. Wireshark:

ip.addr == 169.0.5.10

IP-, Wireshark "Destination unreachable".

, netstat:

c:\>netstat -an | grep 9088
    TCP    169.0.1.126:4295       169.0.5.10:9088        TIME_WAIT

, .

( IP-) :

c:\>netstat -an | grep 9089
    TCP    169.0.1.126:4398       169.0.5.10:9089        SYN_SENT
0

IBM , : From version 3.00.JC1 of IBM® Informix® JDBC Driver onwards, debug drivers are no longer shipped. Informix JDBC Driver now supports SQLIDEBUG. You no longer need to set values for TRACE, TRACEFILE or PROTOCOLTRACE, PROTOCOLTRACEFILE. You only need to set SQLIDEBUG., , . :

  • CLASSPATH Informix JDBC.

    C:\Infx\Java > CLASSPATH = C:\infx\JDBC3.00JC3\Lib\ifxjdbc.jar; C:.\Infx\JDBC3.00JC3\Lib\ifxjdbcx.jar;

  • simple.java

    c:\Infx\Java > javac simple.java

  • , SQLIDEBUG

    c:\Infx\Java > grep SQLIDEBUG simple.java
    Conn = DriverManager.getConnection( "JDBC: Informix-SQLI://: +1526/sysmaster: INFORMIXSERVER = irk940; USER = Informix; PASSWORD = ximrofni; SQLIDEBUG = C:\infx\java\trace" );

    . SQLIDEBUG . , , .. trace.xxxxxxx

  • c:\Infx\Java > del trace *

  • java.simple

    c:\Infx\Java > java simple systables syscolumns...... oledbordinals

  • c:\Infx\Java > dir * C . - B823-46D8

    c:\Infx\Java

    04/04/2006 14:12 20,560 trace1144156355642.0 1 20,560 0 4 067 995 648

    c:\Infx\Java >

    , , .

  • .

, 3.00.JC1 Informix, , ; :

, TRACE, TRACEFILE, PROTOCOLTRACE PROTOCOLTRACEFILE URL- Informix . TRACE ​​ :

  • . .
  • .
  • , 1, .
  • , 2, . TRACEFILE , TRACE.

PROTOCOLTRACE SQLI, Java Informix.

:

  • . .
  • .
  • , 1, . PROTOCOLTRACFILE , PROTOCOLTRACE .

,

0
  • jdbc
  • NETTYPE Informix
  • dump java thread states (kill -3) jdbc
0
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.informix.*;
public class DBConnect {
    static String url="jdbc:informix-sqli://host_name:port/database_name:INFORMIXSERVER=server;user=username;password=password";

    public static void main(String [] args){
        try {
            Class.forName("com.informix.jdbc.IfxDriver");
        }catch (Exception e){
            System.out.println("ERROR: failed to load Informix JDBC driver.");
            e.printStackTrace();
            return;
        }
        try{

            DriverManager.registerDriver((com.informix.jdbc.IfxDriver)Class.forName("com.informix.jdbc.IfxDriver").newInstance());

        }catch(Exception ex){
            System.out.println("Driver is not Registered");
        }
        try{

            Connection conn = DriverManager.getConnection(url);
            System.out.println("Connection Successful");
        }catch (SQLException e){
            System.out.println("ERROR: failed to connect!");
            System.out.println("ERROR: " + e.getMessage());
            e.printStackTrace();
            return;
        }
        }
}

[ ] (http://www.cursor-distribution.de/aktuell.11.70.xC6/documentation/ids_jdbc_bookmap.pdf)

0

The problem I ran into was that Informix was listening on the local IPv6 address on port 7360, the command netstat -adisplayed this format:

TCP    [feab::11ab:78ab:efab:8aab%17]:7360  myhostname:0      LISTENING

So my jdbc connection always failed until it turned out that I should use the IPv6 address in the url:

jdbc:informix-sqli://fe80::1125:78c0:ef17:8ab5%17:7360:user=informix;password=test;INFORMIXSERVER=ol_informix1210_2

You can verify that the connection works with this simple script:

/***************************************************************************
 *
 *  Title:         SimpleConnection.java
 *
 *  Description:    Demo a connection to a server (no database specified)
 *      
 *  An example of running the program: 
 *      
 *   java SimpleConnection 
 *      'jdbc:informix-sqli://myhost:1533:user=<username>;password=<password>'
 *      
 *   Expected result:
 * 
 * >>>Simple Connection test.
 * URL = "jdbc:informix-sqli://myhost:1533:user=<username>;password=<password>"
 * >>>End of Simple Connection test.
 * 
 ***************************************************************************
 */

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class SimpleConnection {

    public static void main(String[] args) {
        if (args.length == 0) {
            System.out.println("FAILED: connection URL must be provided in order to run the demo!");
            return;
        }

        String url = args[0];

        String testName = "Simple Connection";

        Connection conn = null;

        System.out.println(">>>" + testName + " test.");
        System.out.println("URL = \"" + url + "\"");

        try {
            Class.forName("com.informix.jdbc.IfxDriver");
        } catch (Exception e) {
            System.out.println("FAILED: failed to load Informix JDBC driver.");
        }

        try {
            PrintWriter out = new PrintWriter(System.out, true);
            DriverManager.setLogWriter(out);
            conn = DriverManager.getConnection(url);
        } catch (SQLException e) {
            System.out.println("FAILED: failed to connect!");
        }

        try {
            conn.close();
        } catch (SQLException e) {
            System.out.println("FAILED: failed to close the connection!");
        }

        System.out.println(">>>End of " + testName + " test.");
    }
}
0
source

All Articles