If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > getting sqlwarnings from db2 jdbc in java

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-04, 04:33
disaster disaster is offline
Registered User
 
Join Date: Feb 2004
Posts: 24
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
Reply With Quote
  #2 (permalink)  
Old 03-01-04, 14:20
tschiereck tschiereck is offline
Registered User
 
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?



Quote:
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
Reply With Quote
  #3 (permalink)  
Old 03-02-04, 05:28
disaster disaster is offline
Registered User
 
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

Quote:
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?
Reply With Quote
  #4 (permalink)  
Old 03-02-04, 05:55
disaster disaster is offline
Registered User
 
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

Quote:
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On