1 34 package smallsql.junit; 35 36 import java.sql.Connection ; 37 import java.sql.ResultSet ; 38 import java.sql.SQLException ; 39 40 43 public class TestExceptionMethods extends BasicTestCase { 44 45 public void testForwardOnly() throws Exception { 46 Connection con = AllTests.getConnection(); 47 try{ 48 con.createStatement().execute("Create Table ExceptionMethods(v varchar(30))"); 49 50 con.createStatement().execute("Insert Into ExceptionMethods(v) Values('qwert')"); 51 52 ResultSet rs = con.createStatement().executeQuery("Select * from ExceptionMethods"); 53 assertEquals( true, rs.next() ); 54 55 try{ 56 rs.isBeforeFirst(); 57 fail("SQLException 'ResultSet is forward only' should be throw"); 58 }catch(SQLException e){ 59 } 61 62 try{ 63 rs.isFirst(); 64 fail("SQLException 'ResultSet is forward only' should be throw"); 65 }catch(SQLException e){ 66 } 68 69 try{ 70 rs.first(); 71 fail("SQLException 'ResultSet is forward only' should be throw"); 72 }catch(SQLException e){ 73 } 75 76 try{ 77 rs.previous(); 78 fail("SQLException 'ResultSet is forward only' should be throw"); 79 }catch(SQLException e){ 80 } 82 83 try{ 84 rs.last(); 85 fail("SQLException 'ResultSet is forward only' should be throw"); 86 }catch(SQLException e){ 87 } 89 90 try{ 91 rs.isLast(); 92 fail("SQLException 'ResultSet is forward only' should be throw"); 93 }catch(SQLException e){ 94 } 96 97 try{ 98 rs.isAfterLast(); 99 fail("SQLException 'ResultSet is forward only' should be throw"); 100 }catch(SQLException e){ 101 } 103 104 try{ 105 rs.afterLast(); 106 fail("SQLException 'ResultSet is forward only' should be throw"); 107 }catch(SQLException e){ 108 } 110 111 try{ 112 rs.absolute(1); 113 fail("SQLException 'ResultSet is forward only' should be throw"); 114 }catch(SQLException e){ 115 } 117 118 try{ 119 rs.relative(1); 120 fail("SQLException 'ResultSet is forward only' should be throw"); 121 }catch(SQLException e){ 122 } 124 }finally{ 125 dropTable( con, "ExceptionMethods" ); 126 } 127 } 128 129 } 130 | Popular Tags |