Click to See Complete Forum and Search --> : Retrieving SQL code from a DB query


kurent
06-02-2009, 03:29 AM
We do a database query:

javax.naming.InitialContext ctx = new javax.naming.InitialContext();
ds = (javax.sql.DataSource) ctx.lookup("jdbc/DB1");

// ...

con = ds.getConnection("username", "password");
con.setAutoCommit(false);
stmt = con.createStatement();

// ...

rs = stmt.executeQuery("SELECT SOMETHING FROM TABLE WHERE ...");


Now how to get the SQL code returned from the database?

chazzy
06-03-2009, 08:23 PM
which sql code? the error?

kurent
06-04-2009, 01:54 AM
Yes.

chazzy
06-04-2009, 06:21 PM
if you catch the sqlexception, it should be in the result of getMessage

kurent
06-12-2009, 07:16 AM
Oh right! So if no exception -> SQL code = 0.