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.Statement ; 27 import java.sql.PreparedStatement ; 28 import java.sql.ResultSet ; 29 import java.sql.ResultSetMetaData ; 30 import java.sql.SQLException ; 31 import java.sql.SQLWarning ; 32 33 import org.apache.derby.tools.ij; 34 35 47 48 public class repeat { 49 50 51 public static void main(String [] args) { 52 System.out.println("Test repeat starting"); 53 boolean passed = false; 54 try { 55 Connection conn; 56 57 ij.getPropertyArg(args); 60 conn = ij.startJBMS(); 61 62 Statement s = conn.createStatement(); 63 s.execute("create table t (i int)"); 64 65 s.execute("insert into t values(180)"); 66 67 s.execute("insert into t values(180)"); 69 70 PreparedStatement ps1 = conn.prepareStatement("insert into t values(180)"); 72 73 for (int i=1; i<=2; i++) { 74 int rows = ps1.executeUpdate(); 75 76 if (rows != 1) 77 System.out.println("FAIL -- insert wrong number of rows"); 78 } 79 80 conn.close(); 81 82 try { 83 int rows = ps1.executeUpdate(); 84 } catch (Throwable e) { 85 passed = true; 86 } 87 if (!passed) 88 System.out.println("FAIL -- able to insert after disconnect"); 89 90 } catch (Throwable e) { 91 e.printStackTrace(); 92 } 93 94 if (passed) 95 System.out.println("PASS"); 96 System.out.println("Test repeat finished"); 97 } 98 } 99 100 | Popular Tags |