Advertisement
Guest User

Untitled

a guest
May 21st, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. public class H2Test {
  2.     public DataSource dataSource() {
  3.         JdbcDataSource dataSource = new JdbcDataSource();
  4.         dataSource.setUrl("jdbc:h2:./h2/h2");
  5.         return dataSource;
  6.     }
  7.  
  8.     public void doTest() {
  9.         JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource());
  10.         jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS Message (id INTEGER PRIMARY KEY, text TEXT);");
  11.         long startTime = System.currentTimeMillis();
  12.  
  13.         for (int i = 0; i < 3000; i++) {
  14.             jdbcTemplate.update("INSERT INTO Message (id, text) VALUES (" + i + ", '123');");
  15.         }
  16.  
  17.         long endTime = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime);
  18.         System.out.println(endTime);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement