IBM DB2 Manual page 505

Table of Contents

Advertisement

// TRACE_CONNECTS | TRACE_DRDA_FLOWS
c = java.sql.DriverManager.getConnection(databaseURL, properties);
// Change the trace level for all subsequent requests
// on the connection to TRACE_ALL
((com.ibm.db2.jcc.DB2Connection) c).setJccLogWriter(printWriter,
com.ibm.db2.jcc.DB2BaseDataSource.TRACE_ALL);
// The following INSERT is traced using trace level TRACE_ALL
java.sql.Statement s1 = c.createStatement();
s1.executeUpdate("INSERT INTO sampleTable(sampleColumn) VALUES(1)");
s1.close();
// Disable all tracing on the connection
((com.ibm.db2.jcc.DB2Connection) c).setJccLogWriter(null);
// The following SQL insert code is not traced
java.sql.Statement s2 = c.createStatement();
s2.executeUpdate("insert into sampleTable(sampleColumn) values(1)");
s2.close();
c.close();
}
catch(java.sql.SQLException e) {
com.ibm.db2.jcc.DB2ExceptionFormatter.printTrace(e, printWriter,
"[TraceExample]");
}
finally {
cleanup(c, printWriter);
printWriter.flush();
}
}
}
Related reference
"DB2ExceptionFormatter class" on page 344
Chapter 15. Problem diagnosis with the IBM Data Server Driver for JDBC and SQLJ
489

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents