Proper error messages in com.ibm.db2.jcc.b.SqlException

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JuhaM

    Proper error messages in com.ibm.db2.jcc.b.SqlException

    Hi All
    Just wondering if its possible get more descriptive error messages in
    to com.ibm.db2.jcc .b.SqlException . getMessge or toString() methods
    gives only SQL-error codes like:
    SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096

    I am using universal driver...

    Thanks for any help

    Best Regads, Juha

  • Jan Nelken

    #2
    Re: Proper error messages in com.ibm.db2.jcc .b.SqlException

    JuhaM wrote:
    Hi All
    Just wondering if its possible get more descriptive error messages in
    to com.ibm.db2.jcc .b.SqlException . getMessge or toString() methods
    gives only SQL-error codes like:
    SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096
    >
    I am using universal driver...
    >
    Thanks for any help
    >
    Best Regads, Juha
    >
    Try:

    db2 ? sql1218

    from DB2 command line (assuming you installed at least DB2 client).
    If you are using DB2 Jcc Universal driver in T2 connectivity mode - you have
    installed client software.
    If you are using DB2 Jcc Universal driver in T4 connectivity mode (pure lava) -
    you may not have installed client software. In this case you can install DB2
    documentation locally - or use online version available at:



    and search (you can also browse Reference->Messages->SQL Messages) for SQL1218.
    here is link to this message:




    Jan M. Nelken

    Comment

    • Jan Nelken

      #3
      Re: Proper error messages in com.ibm.db2.jcc .b.SqlException

      JuhaM wrote:
      Hi All
      Just wondering if its possible get more descriptive error messages in
      to com.ibm.db2.jcc .b.SqlException . getMessge or toString() methods
      gives only SQL-error codes like:
      SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096
      >
      I am using universal driver...
      >
      Thanks for any help
      >
      Best Regads, Juha
      Try:

      db2 ? sql1218

      from DB2 command line (assuming you installed at least DB2 client).
      If you are using DB2 Jcc Universal driver in T2 connectivity mode - you have
      installed client software.
      If you are using DB2 Jcc Universal driver in T4 connectivity mode (pure java) -
      you may not have installed client software. In this case you can install DB2
      documentation locally - or use online version available at:



      and search (you can also browse Reference->Messages->SQL Messages) for SQL1218.
      here is link to this message:




      Jan M. Nelken

      Comment

      • Serge Rielau

        #4
        Re: Proper error messages in com.ibm.db2.jcc .b.SqlException

        Jan Nelken wrote:
        JuhaM wrote:
        >Hi All
        >Just wondering if its possible get more descriptive error messages in
        >to com.ibm.db2.jcc .b.SqlException . getMessge or toString() methods
        >gives only SQL-error codes like:
        >SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096
        >>
        >I am using universal driver...
        >Thanks for any help
        DB2 9 for LUW has a stored procedure to retrieve the messagetext for any
        SQLCODE in the server language.
        Check under "Administra tive routines"

        Cheers
        Serge
        --
        Serge Rielau
        DB2 Solutions Development
        IBM Toronto Lab

        WAIUG Conference

        Comment

        • JuhaM

          #5
          Re: Proper error messages in com.ibm.db2.jcc .b.SqlException

          Thanks everyone for the help. Actually I was hoping to get error
          messages directly from java, without extra lookup. Perhaps I can use
          this sp somehow..
          Regards, Juha
          Serge Rielau wrote:
          Jan Nelken wrote:
          JuhaM wrote:
          Hi All
          Just wondering if its possible get more descriptive error messages in
          to com.ibm.db2.jcc .b.SqlException . getMessge or toString() methods
          gives only SQL-error codes like:
          SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096
          >
          I am using universal driver...
          Thanks for any help
          DB2 9 for LUW has a stored procedure to retrieve the messagetext for any
          SQLCODE in the server language.
          Check under "Administra tive routines"
          >
          Cheers
          Serge
          --
          Serge Rielau
          DB2 Solutions Development
          IBM Toronto Lab
          >
          WAIUG Conference
          http://www.iiug.org/waiug/present/Fo...Forum2006.html

          Comment

          • Knut Stolze

            #6
            Re: Proper error messages in com.ibm.db2.jcc .b.SqlException

            JuhaM wrote:
            Hi All
            Just wondering if its possible get more descriptive error messages in
            to com.ibm.db2.jcc .b.SqlException . getMessge or toString() methods
            gives only SQL-error codes like:
            SQLCODE: -1218, SQLSTATE: 57011, SQLERRMC: 4096
            You can do this (following the description here:


            try {
            stmt.executeUpd ate("CREATE TABLE t ( a INT )");
            } catch (SQLException e) {
            System.out.prin tln("SQL Exception");
            System.out.prin tln("========== ===");
            System.out.prin tln(e.getMessag e()); // (1)
            System.out.prin tln("");
            if (e instanceof DB2Diagnosable) {
            DB2Diagnosable db2e = (DB2Diagnosable )e;
            DB2Sqlca sqlca = db2e.getSqlca() ;
            System.out.prin tln(sqlca.getMe ssage()); // (2)
            }
            }

            You will see in step (1) the error message that contains the sqlcode,
            sqlstate, and tokens - which you posted above. On step (2) you will
            receive the short message for the error. Or do you need the long error
            message, which includes Explanation and User Response, i.e. exactly what
            this would return:

            $ db2 "? sql0601"


            Here is an example of the output I got:

            $ javac A.java && java A
            SQL Exception
            =============
            DB2 SQL error: SQLCODE: -601, SQLSTATE: 42710, SQLERRMC: STOLZE.T;TABLE

            The name of the object to be created is identical to the existing
            name "STOLZE.T" of type "TABLE".

            --
            Knut Stolze
            DB2 z/OS Utilities Development
            IBM Germany

            Comment

            Working...