1 21 22 package org.apache.derbyTesting.functionTests.tests.lang; 23 24 import java.sql.Connection ; 25 import java.sql.DriverManager ; 26 import java.sql.ResultSetMetaData ; 27 import java.sql.ResultSet ; 28 import java.sql.Statement ; 29 import java.sql.SQLException ; 30 import java.sql.Types ; 31 import java.sql.*; 32 33 import org.apache.derby.tools.ij; 34 import org.apache.derby.tools.JDBCDisplayUtil; 35 36 37 45 46 public class bug5052rts { 47 48 public static void main(String [] args) { 49 Connection conn; 50 Statement stmt; 51 PreparedStatement pstmt; 52 53 System.out.println("Test RunTime Statistics starting"); 54 try 55 { 56 ij.getPropertyArg(args); 59 conn = ij.startJBMS(); 60 stmt = conn.createStatement(); 61 try{ 62 stmt.execute("drop table tab1"); 63 }catch(Throwable e ) {} 64 65 stmt.execute("create table tab1 (COL1 int, COL2 smallint, COL3 real)"); 67 stmt.executeUpdate("insert into tab1 values(1, 2, 3.1)"); 68 stmt.executeUpdate("insert into tab1 values(2, 2, 3.1)"); 69 conn.setAutoCommit( false ); 70 71 if(true) 73 { 74 Statement stmt0 = conn.createStatement(); 75 ResultSet rs = stmt0.executeQuery("select * from tab1"); 77 while ( rs.next() ) { 78 System.out.println(rs.getString(1)); 79 } 80 CallableStatement cs = 82 conn.prepareCall( 83 "CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(?)"); 84 cs.setInt(1, 1); 85 cs.execute(); 86 cs.close(); 87 88 rs.close(); 89 stmt0.close(); 90 } 91 92 CallableStatement cs = 93 conn.prepareCall( 94 "CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(?)"); 95 cs.setInt(1, 0); 96 cs.execute(); 97 cs.close(); 98 99 if(true) 101 { 102 Statement stmt1 = conn.createStatement(); 103 ResultSet rs = stmt1.executeQuery("select * from tab1"); 105 while ( rs.next() ) { 106 System.out.println(rs.getString(1)); 107 } 108 cs = conn.prepareCall( 110 "CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(?)"); 111 cs.setInt(1, 1); 112 cs.execute(); 113 cs.close(); 114 } 115 116 117 if(true) 118 { 119 Statement stmt2 = conn.createStatement(); 120 ResultSet rs1 = stmt2.executeQuery("select count(*) from tab1"); 122 while ( rs1.next() ) { 123 System.out.println(rs1.getString(1)); 124 } 125 } 126 127 128 for(int i = 0 ; i < 3 ; i++){ 129 System.gc(); 130 System.runFinalization(); 131 Thread.sleep(3000); 134 } 135 136 conn.commit(); conn.close(); 138 } 139 140 catch (SQLException e) { 141 dumpSQLExceptions(e); 142 e.printStackTrace(); 143 } 144 catch (Throwable e) { 145 System.out.println("FAIL -- unexpected exception: "+e); 146 e.printStackTrace(); 147 } 148 System.out.println("Test RunTimeStatistics finished successfully"); 149 } 150 151 static private void dumpSQLExceptions (SQLException se) { 152 System.out.println("FAIL -- unexpected exception"); 153 while (se != null) { 154 System.out.println("SQLSTATE("+se.getSQLState()+"): "+se); 155 se = se.getNextException(); 156 } 157 } 158 159 } 160 161 162 163 164 165 166 167 | Popular Tags |