views:

4

answers:

0

Hey I wrote a test java application that uses sqlitejdbc. I was wondering if there was a way to obtain a transaction log that displays the way that the application communicated with the database while it ran. heres what I have written:

Class.forName("org.sqlite.JDBC"); Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");

Statement stat = conn.createStatement(); stat.executeUpdate("drop table if exists car;"); //create statement stat.executeUpdate("create table car (pk INTEGER PRIMARY KEY, model VARCHAR(30), price DOUBLE, society VARCHAR(30));"); PreparedStatement prep = conn.prepareStatement( "insert into car values (?, ?, ?, ?);");

System.out.println("Table Car Created");

prep.setString(1, "1"); prep.setString(2, "'ml'"); prep.setString(3, "8000"); prep.setString(4, "'GM'"); prep.addBatch();

prep.setString(1, "2"); prep.setString(2, "'m2'"); prep.setString(3, "15000"); prep.setString(4, "'Ford'"); prep.addBatch();

  conn.setAutoCommit(false);
  prep.executeBatch();
  conn.setAutoCommit(true);

//select statement ResultSet rs = stat.executeQuery("select * from car;"); while (rs.next()) { System.out.print("model = " + rs.getString("model")); System.out.print(", price = " + rs.getString("price")); System.out.println(", society = " + rs.getString("society")); }

System.out.println("select statement worked");

//update statement stat.executeUpdate("update car set \"price\" = 30000, \"society\" = 'Toyota' where \"pk\" = 2;"); rs = stat.executeQuery("select * from car;"); while (rs.next()) { System.out.print("model = " + rs.getString("model")); System.out.print(", price = " + rs.getString("price")); System.out.println(", society = " + rs.getString("society")); }

System.out.println("update statement worked"); //delete statement stat.executeUpdate("delete from car where \"price\" = 8000;"); rs = stat.executeQuery("select * from car;"); while (rs.next()) { System.out.print("model = " + rs.getString("model")); System.out.print(", price = " + rs.getString("price")); System.out.println(", society = " + rs.getString("society")); }

System.out.println("delete statement worked");

  rs.close();
  conn.close();

-thank you for your time