Advertisement
salahzar

h2 access

May 17th, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import org.apache.commons.lang.time.StopWatch;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.Statement;
  6. import java.util.Properties;
  7.  
  8. public class H2Access {
  9.     public static void main(String[] args) throws Exception {
  10.         Class.forName("org.h2.Driver");
  11.         Properties props = new Properties();
  12.         props.setProperty("user","sa");
  13.         props.setProperty("password","test");
  14.         Connection conn = DriverManager.getConnection("jdbc:h2:tcp://localhost/~/h2/test",props);
  15.         Statement stat = conn.createStatement();
  16.         StopWatch stopwatch = new StopWatch();
  17.         stopwatch.start();
  18.         for (int i = 0; i < 1000000; i++) {
  19.  
  20.             stat.execute("insert into test(id,name,field,f2) values(nextval('RESTART'),'Hello','a','a')");
  21.         }
  22.  
  23.         stopwatch.stop();
  24.         long timeTaken = stopwatch.getTime();
  25.         System.out.println("Done in "+timeTaken);
  26.         conn.close();
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement