1 24 25 package org.objectweb.cjdbc.scenario.users; 26 27 import java.sql.Connection ; 28 import java.sql.DriverManager ; 29 import java.sql.SQLException ; 30 import java.sql.Statement ; 31 import java.util.Random ; 32 33 77 public class WillemScenario 78 { 79 String driver = "org.objectweb.cjdbc.driver.Driver"; 80 String url = "jdbc:cjdbc://localhost/m4ncluster"; 81 String username = "m4ncluster"; 82 String password = "clusterm4n"; 83 int records = 50000; 84 long waitTime = 100000; 85 Connection connection = null; 86 Random random = null; 87 88 91 public WillemScenario() 92 { 93 try 94 { 95 Class.forName(driver).newInstance(); 96 connection = DriverManager.getConnection(url, username, password); 97 98 random = new Random (); 99 fillDB(); 100 } 101 catch (SQLException e) 102 { 103 System.err.println("SQLException: " + e.getMessage()); 104 } 105 catch (ClassCastException e) 106 { 107 System.err.println("ClassCastException: " + e.getMessage()); 108 } 109 catch (ClassNotFoundException e) 110 { 111 System.err.println("ClassNotFoundException: " + e.getMessage()); 112 } 113 catch (InstantiationException e) 114 { 115 System.err.println("InstantiationException: " + e.getMessage()); 116 } 117 catch (IllegalAccessException e) 118 { 119 System.err.println("IllegalAccessException: " + e.getMessage()); 120 } 121 } 122 123 126 public void fillDB() 127 { 128 try 129 { 130 Statement sm = connection.createStatement(); 131 for (int i = 0; i < records; i++) 132 { 133 String sql = "insert into test (test) values (" 134 + random.nextInt(873264) + ")"; 135 System.out.println("sql: " + sql); 136 sm.executeUpdate(sql); 137 for (int r = 0; r < 3000; ++r) 139 { 140 } 141 } 142 } 143 catch (SQLException e) 144 { 145 System.err.println("Could not fill test: " + e.getMessage()); 146 } 147 } 148 149 154 static public void main(String [] args) 155 { 156 new WillemScenario(); 157 } 158 } | Popular Tags |