1 24 25 package org.objectweb.cjdbc.scenario.raidb1.startup; 26 27 import java.sql.Connection ; 28 import java.sql.PreparedStatement ; 29 import java.sql.ResultSet ; 30 import java.util.ArrayList ; 31 32 import org.objectweb.cjdbc.controller.core.Controller; 33 import org.objectweb.cjdbc.scenario.templates.Raidb1Template; 34 35 41 public class ControllerStopScenario extends Raidb1Template 42 { 43 48 49 public void testReconnectAfterFailure() throws Exception 50 { 51 52 ArrayList list = new ArrayList (); 53 54 Connection con = getCJDBCConnection(); 56 PreparedStatement stmt = con 57 .prepareStatement("create table ATEST (id int, text varchar(1000))"); 58 stmt.executeUpdate(); 59 60 stmt = con.prepareStatement("insert into ATEST (id,text) values (?,?)"); 61 62 for (int i = 0; i < 100; i++) 63 { 64 65 stmt.setInt(1, i); 66 stmt 67 .setString( 68 2, 69 "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus quam nunc, dignissim sit amet, placerat at, feugiat quis, purus. Vivamus suscipit elementum velit. Nam ac libero. Mauris fermentum ultricies felis. Suspendisse tempor consectetuer risus. Aenean rutrum, orci sit amet tristique congue, mauris libero luctus nibh, vitae malesuada magna nulla nec velit. Etiam dapibus aliquet justo. Pellentesque posuere urna sit amet nunc. Fusce augue quam, venenatis a, ornare id, convallis non, leo. Aliquam laoreet tortor sit amet wisi. Donec dolor."); 70 stmt.execute(); 71 } 72 73 ResultSet rs = stmt.executeQuery("select * from ATEST"); 74 while (rs.next()) 75 { 76 list.add(rs.getString("text")); 77 } 78 79 cm.stop(25322); 81 82 controller = (Controller) cm.start("25322").getProcess(); 84 cm.loaddatabase("25322", "hsqldb-raidb1.xml"); 85 mainVdb = controller.getVirtualDatabase("myDB"); 86 mainVdb.enableAllBackends(); 87 88 90 stmt.setFetchSize(5); 92 for (int i = 0; i < 1000; i++) 93 { 94 System.out.println("continue " + i + " " 95 + Runtime.getRuntime().freeMemory() / 1000000f); 96 stmt.setInt(1, i); 97 stmt 98 .setString( 99 2, 100 "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus quam nunc, dignissim sit amet, placerat at, feugiat quis, purus. Vivamus suscipit elementum velit. Nam ac libero. Mauris fermentum ultricies felis. Suspendisse tempor consectetuer risus. Aenean rutrum, orci sit amet tristique congue, mauris libero luctus nibh, vitae malesuada magna nulla nec velit. Etiam dapibus aliquet justo. Pellentesque posuere urna sit amet nunc. Fusce augue quam, venenatis a, ornare id, convallis non, leo. Aliquam laoreet tortor sit amet wisi. Donec dolor."); 101 stmt.execute(); 102 103 rs = stmt.executeQuery("select * from ATEST"); 105 } 110 } 111 } 112 | Popular Tags |