Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Advanced
Apr 23, 1999

Setting the Log Stream

When debugging Java Database Connectivity (JDBC) problems, it can be difficult to locate the source of errors. However, one facility that can be used to accomplish this is the logging/tracing stream used by JDBC. Most JDBC drivers write information to the stream that can be helpful in debugging errors. You can take advantage of this fact by redirecting the output so that you're able to review it. Simply call the static setLogStream() method in the java.sql.DriverManager class, specifying a java.io.PrintStream instance representing the desired destination of the output. This code redirects the JDBC drivers' diagnostic messages to the console:
 
DriverManager.setLogStream(System.out);
If you wish to store the output in a file, simply create a PrintStream instance that represents a disk file:
 
FileOutputStream fos = new FileOutputStream("jdbclog.txt");
PrintStream ps = new PrintStream(fos);
DriverManager.setLogStream(ps);
Brett Spell
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap