Handling no group on Aggregates
[csql.git] / test / performance / JDBCExecTest.java
blob1d3007dbf496e54c3b82e2a879986f0ee2bb45d0
1 import java.sql.*;
2 public class JDBCExecTest
4 public static void main(String[] args)
6 try
8 Class.forName("csql.jdbc.JdbcSqlDriver");
9 Connection con = DriverManager.getConnection("jdbc:csql", "root", "manager");
10 Statement cStmt = con.createStatement();
11 cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (194));");
12 System.out.println("Table t1 created");
13 cStmt.execute("CREATE INDEX IDX ON T1 (f1) ;");
14 System.out.println("Primary Index created on T1 (f1) ");
15 cStmt.close();
16 con.commit();
18 Statement stmt = con.createStatement();
19 String sql = "INSERT INTO T1 (f1, f2) VALUES (1, 'DummyValue');";
20 int count =0;
21 int ret =0;
22 long start =0, end =0, curr =0;
23 long min =100000, max =0, tot =0;
24 for (int i =0 ; i<= 100 ; i++) {
25 start = System.nanoTime();
26 ret = stmt.executeUpdate(sql);
27 if (ret != 1) break; //error
28 end = System.nanoTime();
29 if (i ==0) continue;
30 curr = end-start;
31 tot = tot + curr;
32 if (min > curr) min = curr;
33 if (max < curr) max = curr;
34 count++;
37 con.commit();
38 System.out.println("Total Rows inserted " + count );
39 System.out.println(" Min:" + min+ " Max: "+max+" Avg: "+ tot/100 );
41 count=0;
42 start=0; end=0; curr=0;
43 min=100000; max=0;tot =0;
44 sql = "SELECT * from T1 where f1 = 6;";
45 ResultSet rs = null;
46 int intVal =0;
47 String strVal = null;
48 for (int i =0 ; i<= 100 ; i++) {
49 start = System.nanoTime();
50 rs = stmt.executeQuery(sql);
51 if (rs.next())
55 rs.close();
56 end = System.nanoTime();
57 if (i ==0) continue;
58 curr = end-start;
59 tot = tot + curr;
60 if (min > curr) min = curr;
61 if (max < curr) max = curr;
62 count++;
64 con.commit();
65 System.out.println("Total Rows selected " + count);
66 System.out.println(" Min:" + min+ " Max: "+max+" Avg: "+ tot/100 );
69 cStmt.execute("DROP TABLE T1;");
70 System.out.println("Dropped table T1");
71 cStmt.close();
73 con.close();
75 catch(Exception e) {
76 System.out.println("Exception in Test: "+e);
77 e.printStackTrace();