Code example for SQLException

Methods: getMessage, printStackTrace

0
 
        // non numeric field 
        try { 
            rsmd.getPrecision(3);
        } catch (SQLException e1) {
            System.out.println("ResultSetMetaDataTest.testGetPrecision()"+e1.getMessage());
            e1.printStackTrace();
        } 
 
 
        try { 
            rsmd.getPrecision(0);
            fail("SQLException is not thrown"); 
        } catch (SQLException e) {
            // expected 
        } 
        try { 
            rsmd.getPrecision(5);
            fail("SQLException is not thrown"); 
        } catch (SQLException e) {
            // expected