import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author  guerin
 */
public class DBCacheTester {
    
    static int total = 0;
    /** Creates a new instance of DBCacheTester */
    public DBCacheTester() {
    }
    
    public static void main(String[] args) throws Exception {
      Thread t[] = new Thread[10];
      for (int x = 0; x<10; x++) {
        t[x] = new Thread("Thread: " + x ) { 
            public void run() {
              try {
                Class.forName("org.postgresql.Driver");
                Connection c = DriverManager.getConnection("jdbc:postgresql://mite01:5432/fiasco", "fiasco", "");
                Statement st = c.createStatement();
                ResultSet rs = null;
                int i = 0;
                while (true) {
                    st.execute("select * into temp table t from fnGetCompositeIds2(33);");
                    st.execute("drop table t;");
                    System.out.println("Thread: " + Thread.currentThread().getName() + "    Iteration: " + i++ + "     Total calls:" + total++);
                }
              } catch (SQLException e) {
                    System.out.println(e);
              } catch (ClassNotFoundException e) {
                  
              }
            }
        };
        t[x].start();
      }
    }
}

