db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Army <qoz...@sbcglobal.net>
Subject Re: jdbc trace
Date Wed, 03 Aug 2005 17:57:11 GMT
Veaceslav Chicu wrote:
> it's ok
> can I redirect this information to console?

If the info you want is the info from setting "derby.language.logStatementText" 
to true, then you can redirect it to output using Stanley's suggestion (see his 
original response to your email).

Ex. If your program is called "myProg", then the following would run your 
program and redirect all of "logStatementText" info to System.out:

java -Dderby.language.logStatementText=true 
-Dderby.stream.error.field=java.lang.System.out myProg

If that does what you want, then you don't have to worry about "setLogWriter()" 
and can stop reading now :)

> I have:
> Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
> Connection conn = DriverManager.getConnection("jdbc:derby:bookstoredb;",
> "slavic", "cs");
> DriverManager.setLogWriter(new PrintWriter(new
> FileOutputStream("trace.txt")));
> why trace.txt is empty? why I don't see log information there?

1) The documentation at the links you pasted says that 
DriverManager.setLogWriter() has to be called BEFORE the connection is made. 
The code snippet that you pasted connects first, and then calls setLogWriter(), 
so it won't work.

2) For completeness, you should make sure you are flushing/closing the 
PrintWriter stream before terminating your program.

3) If you really want the information that is written by "setLogWriter()" 
(instead of the information that is written when derby.language.logStatementText 
is true), and if you want to redirect that output to the console, then your code 
should look like this:

	PrintWriter pW = new PrintWriter(System.out);

	Connection conn =
		"slavic", "cs");

Hope that helps,

View raw message