Enable JDBC logging : Driver « Database SQL JDBC « Java






Enable JDBC logging

   
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class Main {
  public static void main(String args[]) throws Exception {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String URL = "jdbc:odbc:dbName";
    Connection dbConn = DriverManager.getConnection(URL, "user", "pass");
    PrintWriter w = new PrintWriter(new OutputStreamWriter(System.out));
    DriverManager.setLogWriter(w);
    dbConn.close();

    PreparedStatement prepstmt;
    prepstmt = dbConn.prepareStatement("SELECT id FROM employee");
    prepstmt.execute();
    prepstmt.close();
    dbConn.close();
  }
}

   
    
    
  








Related examples in the same category

1.Get Driver Property Info
2.Get Driver Name
3.int java.sql.Driver.getMajorVersion()
4.int java.sql.Driver.getMinorVersion()
5.boolean java.sql.Driver.jdbcCompliant()
6.Enumeration java.sql.DriverManager.getDrivers()
7.Get Driver Version
8.JDBC Driver Information
9.Loading a JDBC Driver: call Class.forName() within the code
10.Listing All Loaded JDBC Drivers and gets information about each one.
11.DriverPropertyInfo[] java.sql.Driver.getPropertyInfo(String url, Properties info)
12.JDBC driver url