Monday, October 20, 2014

Java Coding Care3: Use DBSPY for Database related issue tracking

Topic : DB SPY

log4jdbc SPY should be use for DB related issue Tracking/Logs

Advantage
It is useful to SPY / DEBUG database related issue tracking. It generates all kind of user
required logs


Libs Required
log4j-1.2.16.jar
log4jdbc4-1.2.jar
log4j-over-slf4j-1.7.5.jar
slf4j-api.jar"
slf4j-jdk14.jar"
slf4j-log4j12-1.7.5.jar"
slf4j-simple-1.7.5.jar"

ojdbc6-11.0.2.0.jar"

Example
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class SpyEngine {

public static void main(String[] rk) {

try {

  Class.forName("net.sf.log4jdbc.DriverSpy");
Connection conn = DriverManager.getConnection( "jdbc:log4jdbc:oracle:thin:@192.168.8.87:1521:rajdb", "rajusername", "rajpassword");

PreparedStatement prStmt = conn.prepareStatement("select * from tbdata");
prStmt.execute();
prStmt.close();

  conn.close();
 
} catch (Exception e) {
System.out.println("Error: " + e);

}
}

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...