1 24 25 package org.objectweb.cjdbc.scenario.raidb1.loadbalancer; 26 27 import java.sql.Connection ; 28 import java.sql.PreparedStatement ; 29 import java.sql.Statement ; 30 31 import org.objectweb.cjdbc.scenario.templates.Raidb1RecoveryTemplate; 32 import org.objectweb.cjdbc.scenario.tools.ScenarioUtility; 33 34 40 public class EnableDisableBackendScenario extends Raidb1RecoveryTemplate 41 { 42 47 public void testDeadLockInUniqueConstraintViolation() throws Exception 48 { 49 Connection aConnection = getCJDBCConnection(); 50 Statement stmt = aConnection.createStatement(); 51 stmt 52 .executeUpdate("create table test2 (id int, CONSTRAINT test_PK PRIMARY KEY(id))"); 53 PreparedStatement insert = aConnection 54 .prepareStatement("insert into test2 (id) values (?)"); 55 insert.setInt(1, 1); 56 insert.executeUpdate(); 57 58 mainVdb.disableBackendWithCheckpoint("localhost"); 59 mainVdb.enableBackendFromCheckpoint("localhost"); 60 61 String query = "select * from test2"; 62 63 Connection hsqlcon = getHypersonicConnection(9001); 64 ScenarioUtility.displaySingleQueryResult(query, hsqlcon); 65 Connection hsqlcon2 = getHypersonicConnection(9002); 66 ScenarioUtility.displaySingleQueryResult(query, hsqlcon2); 67 68 PreparedStatement insert2 = aConnection 69 .prepareStatement("insert into test2 (id) values (?)"); 70 insert2.setInt(1, 2); 71 insert2.executeUpdate(); 72 73 hsqlcon = getHypersonicConnection(9001); 74 ScenarioUtility.displaySingleQueryResult(query, hsqlcon); 75 hsqlcon2 = getHypersonicConnection(9002); 76 ScenarioUtility.displaySingleQueryResult(query, hsqlcon2); 77 } 78 } | Popular Tags |