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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date