Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-13-2008, 01:30 PM
Moderator
 
Join Date: Nov 2007
Posts: 1,657
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Enabling JDBC logging (example)
The example presented below shows how to enable JDBC logging.

Code:
class JDBCapp { static MyConnection theConn; public static void main (String args[]) { new JDBCapp().doit(); } public void doit() { theConn = new MyConnection(); theConn.connect("EAS Demo DB V3", "dba", "sql"); PreparedStatement prepstmt; try { prepstmt = theConn.dbConn.prepareStatement ("SELECT emp_id FROM employee" ); prepstmt.execute(); prepstmt.close(); } catch (Exception e) { e.printStackTrace(); } theConn.disconnect(); } } class MyConnection { Connection dbConn = null; void connect(String db, String user, String passw) { try { Driver d = (Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); String URL = "jdbc:odbc:" + db; dbConn = DriverManager.getConnection(URL, user, passw); java.io.PrintWriter w = new java.io.PrintWriter (new java.io.OutputStreamWriter(System.out)); DriverManager.setLogWriter(w); } catch (Exception e) { e.printStackTrace(); } } void disconnect() { try { dbConn.close(); } catch (Exception e) { e.printStackTrace(); } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-13-2008, 08:28 PM
itgalary's Avatar
Member
 
Join Date: Feb 2008
Posts: 6
itgalary is on a distinguished road
Nice article.. will help many
__________________
Free Programming help
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use JDBC Template classes to control basic JDBC processing and error handling Java Tip Java Tips 0 04-01-2008 12:17 PM
what is logging Thirumalt Java Announcements 1 11-26-2007 01:37 PM
Logging ravian New To Java 3 11-19-2007 12:22 AM
How to use JDBC Template classes to control basic JDBC processing and error handling JavaBean Java Tips 0 09-28-2007 02:56 PM
Java Logging vaswin Advanced Java 0 08-06-2007 03:18 PM


All times are GMT +3. The time now is 06:31 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org