1 24 25 package org.objectweb.cjdbc.scenario.raidb1.pool; 26 27 import java.sql.Connection ; 28 import java.sql.PreparedStatement ; 29 import java.sql.SQLException ; 30 import java.sql.Statement ; 31 32 import org.objectweb.cjdbc.scenario.templates.SimpleRaidb1Template; 33 34 40 public class VariablePoolScenario extends SimpleRaidb1Template 41 { 42 45 protected void setUp() 46 { 47 super.setUp(); 48 try 49 { 50 cm.loadVirtualDatabases(controller, "myDB", "hsqldb-thinks-oracle.xml"); 51 mainVdb = controller.getVirtualDatabase("myDB"); 52 mainVdb.enableAllBackends(); 53 } 54 catch (Exception e) 55 { 56 e.printStackTrace(); 57 } 58 } 59 60 65 public void testGetManyConnection() throws Exception 66 { 67 Connection aConnection = getCJDBCConnection(); 68 aConnection.setAutoCommit(false); 69 Statement stmt = aConnection.createStatement(); 70 try 71 { 72 stmt.executeUpdate("drop table test2"); 73 } 74 catch (SQLException ignore) 75 { 76 } 78 stmt 79 .executeUpdate("create table test2 (id int, CONSTRAINT test_PK PRIMARY KEY(id))"); 80 PreparedStatement insert = aConnection 81 .prepareStatement("insert into test2 (id) values (?)"); 82 insert.setInt(1, 1); 83 insert.executeUpdate(); 84 aConnection.commit(); 85 aConnection.setAutoCommit(true); 86 aConnection.setAutoCommit(false); 87 insert = aConnection.prepareStatement("insert into test2 (id) values (?)"); 88 insert.setInt(1, 2); 89 insert.executeUpdate(); 90 aConnection.commit(); 91 aConnection.setAutoCommit(true); 92 aConnection.close(); 93 } 94 } | Popular Tags |