1 24 25 package org.objectweb.cjdbc.scenario.tools.testlet; 26 27 import java.sql.Connection ; 28 import java.sql.PreparedStatement ; 29 import java.sql.Statement ; 30 import java.util.Properties ; 31 32 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase; 33 34 40 public class MacroStatementTestLet extends AbstractVdbTestLet 41 { 42 static final String UPDATE = "update ADDRESS set FIRSTNAME="; 43 44 49 public MacroStatementTestLet(VirtualDatabase vdb) 50 { 51 super(vdb); 52 set(MACRO_NAME, "now()"); 53 set(USE_OPTIMIZED_STATEMENT, "true"); 54 set(USE_PREPARED_STATEMENT, "true"); 55 set(USE_UPDATE_STATEMENT, "true"); 56 } 57 58 61 public void execute() throws Exception 62 { 63 boolean useOptimized = getConfigBoolean(USE_OPTIMIZED_STATEMENT); 64 boolean usePrepared = getConfigBoolean(USE_PREPARED_STATEMENT); 65 boolean useUpdate = getConfigBoolean(USE_UPDATE_STATEMENT); 66 String statement = UPDATE + ((String ) config.get(MACRO_NAME)); 67 68 Properties props = new Properties (); 69 if (useOptimized) 70 props.put("driverProcessed", "false"); 71 Connection con = getCJDBCConnection(props); 72 if (usePrepared) 73 { 74 PreparedStatement st = con.prepareStatement(statement); 75 if (useUpdate) 76 st.executeUpdate(); 77 else 78 st.executeQuery(); 79 } 80 else 81 { 82 Statement st = con.createStatement(); 83 if (useUpdate) 84 st.executeUpdate(statement); 85 else 86 st.executeQuery(statement); 87 } 88 } 89 90 } | Popular Tags |