1 21 22 package org.apache.derbyTesting.functionTests.tests.store; 23 24 25 import org.apache.derby.iapi.services.sanity.SanityManager; 26 27 import java.sql.CallableStatement ; 28 import java.sql.Connection ; 29 import java.sql.PreparedStatement ; 30 import java.sql.ResultSet ; 31 import java.sql.SQLException ; 32 import java.sql.Statement ; 33 34 import org.apache.derby.tools.ij; 35 36 37 85 86 public class dropcrash extends BaseTest 87 { 88 boolean verbose = false; 89 90 public dropcrash() 91 { 92 } 93 94 97 public void drop_crash_setup( 98 Connection conn, 99 int num_create) 100 throws SQLException 101 { 102 beginTest(conn, "creating " + num_create + " tables."); 103 String create_stmt_str1 = "create table dropcrash_"; 104 String create_stmt_str2 = " (a int)"; 105 106 for (int i = 0; i < num_create; i++) 107 { 108 executeQuery(conn, create_stmt_str1 + i + create_stmt_str2, false); 109 } 110 conn.commit(); 111 112 executeQuery( 116 conn, "CALL SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()", false); 117 118 endTest(conn, "creating " + num_create + " tables."); 119 } 120 121 132 public void drop_crash_drop_table(Connection conn) 133 throws SQLException 134 { 135 beginTest(conn, "dropping table with conglomerate number 2080."); 136 PreparedStatement ps = 137 conn.prepareStatement( 138 "select sys.systables.tablename, sys.sysconglomerates.conglomeratenumber from sys.systables, sys.sysconglomerates where sys.systables.tableid = sys.sysconglomerates.tableid and sys.systables.schemaid = sys.sysconglomerates.schemaid and sys.sysconglomerates.conglomeratenumber = ?"); 139 ps.setInt(1, 2080); 140 ResultSet rs = ps.executeQuery(); 141 142 if (!rs.next()) 143 { 144 System.out.println("ERROR, did not find conglomerate to drop"); 145 } 146 String drop_name = rs.getString(1); 147 148 executeQuery(conn, "drop table " + drop_name, false); 152 conn.commit(); 153 154 endTest(conn, "dropping table with conglomerate number 2080."); 158 } 159 160 public void testList(Connection conn) 161 throws SQLException 162 { 163 drop_crash_setup(conn, 500); 165 drop_crash_drop_table(conn); 167 } 168 169 public static void main(String [] argv) 170 throws Throwable 171 { 172 dropcrash test = new dropcrash(); 173 174 ij.getPropertyArg(argv); 175 Connection conn = ij.startJBMS(); 176 conn.setAutoCommit(false); 177 178 try 179 { 180 test.testList(conn); 181 } 182 catch (SQLException sqle) 183 { 184 org.apache.derby.tools.JDBCDisplayUtil.ShowSQLException( 185 System.out, sqle); 186 sqle.printStackTrace(System.out); 187 } 188 } 189 } 190 | Popular Tags |