1 3 package org.prevayler.demos.scalability.jdbc; 4 5 import org.prevayler.demos.scalability.*; 6 import java.sql.*; 7 8 9 abstract class JDBCScalabilitySubject implements ScalabilityTestSubject { 10 11 protected final String connectionURL; 12 protected final String user; 13 protected final String password; 14 15 {System.gc();} 16 17 18 protected JDBCScalabilitySubject(String jdbcDriverClassName, String connectionURL, String user, String password) { 19 try { 20 Class.forName(jdbcDriverClassName); 21 } catch (Exception ex) { 22 ex.printStackTrace(); 23 throw new RuntimeException ("Exception loading JDBC driver class: " + jdbcDriverClassName); 24 } 25 26 this.connectionURL = connectionURL; 27 this.user = user; 28 this.password = password; 29 } 30 31 public String name() { 32 return "JDBC"; 33 } 34 35 public void replaceAllRecords(int records) { 36 ((JDBCScalabilityConnection)createTestConnection()).replaceAllRecords(records); 37 } 38 39 protected Connection createConnection() { 40 try { 41 42 return DriverManager.getConnection(connectionURL, user, password); 43 44 } catch (SQLException sqlx) { 45 sqlx.printStackTrace(); 46 throw new RuntimeException ("Exception while trying to connect: " + sqlx); 47 } 48 } 49 } 50 | Popular Tags |