Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    24

    Unanswered: getting sqlwarnings from db2 jdbc in java

    Hi,

    we got some problems with java and db2 jdbc type 2 (connecting to db2 v7 on z/os) and sqlcodes > 0. is it possible to get the warning codes (like sqlcode=100) from the jdbc? in the case of sqlcode > 0 there is no sqlexception to catch to get the sqlwarnings. i searched for the sqlca. after decompiling the whole jdbc driver i found the sqlca but it will not be populated by the driver.

    any idea ?

    marc

  2. #2
    Join Date
    Feb 2004
    Posts
    9

    Re: getting sqlwarnings from db2 jdbc in java

    I believe there is a getWarnings() method on the statement object. If there is an actual compile problem with the statement, then you will get an exception. Does the statement run interactively via the desktop client?



    Originally posted by disaster
    Hi,

    we got some problems with java and db2 jdbc type 2 (connecting to db2 v7 on z/os) and sqlcodes > 0. is it possible to get the warning codes (like sqlcode=100) from the jdbc? in the case of sqlcode > 0 there is no sqlexception to catch to get the sqlwarnings. i searched for the sqlca. after decompiling the whole jdbc driver i found the sqlca but it will not be populated by the driver.

    any idea ?

    marc

  3. #3
    Join Date
    Feb 2004
    Posts
    24

    Re: getting sqlwarnings from db2 jdbc in java

    hi,

    thx for reply the post. we are developing our own product to execute sql statement interactiv. the getwarnings() is declared for all interesting objects like the connection, resultset and statement but if we prepare a statement and execute it after that we try to get the sqlwarnings without reposinitioning the cursor for the resultset and getting a null for sqlwarnings all the time. i don't what we else can do !!!

    please help us !

    marc gaines

    Originally posted by tschiereck
    I believe there is a getWarnings() method on the statement object. If there is an actual compile problem with the statement, then you will get an exception. Does the statement run interactively via the desktop client?

  4. #4
    Join Date
    Feb 2004
    Posts
    24

    Re: getting sqlwarnings from db2 jdbc in java

    hi again,

    here's an example of a query and it's java code.
    a resultset with no rows (empty) is coming back.

    try {
    String db2drl = new String("select * from qx05714.person where penr = 1999;");

    ResultSet rs = stmt.executeQuery(db2drl);

    SQLWarning sqlwarn = stmt.getWarnings();

    if ( sqlwarn != null ) {
    System.out.println( "SQLWarning: "+sqlwarn.getSQLState() );
    } else {
    System.out.println("No warnings avail.");
    }

    } catch (SQLException sqle) {
    System.out.println("SQLException-SQLState: "+sqle.getSQLState());
    System.out.println("SQLException-Message: "+sqle.getMessage());
    } catch (Exception ex) {
    System.out.println(ex);
    ex.printStackTrace();
    }

    All what we are getting is No warnings avail.
    But i want to see sqlstate 02000.

    regards

    marc gaines

    Originally posted by disaster
    hi,

    thx for reply the post. we are developing our own product to execute sql statement interactiv. the getwarnings() is declared for all interesting objects like the connection, resultset and statement but if we prepare a statement and execute it after that we try to get the sqlwarnings without reposinitioning the cursor for the resultset and getting a null for sqlwarnings all the time. i don't what we else can do !!!

    please help us !

    marc gaines

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •