public void testGetScale() throws SQLException {
  try {
    int scale=3;
    String createTable="create table DecimalNumbers ( valueDouble DOUBLE," + "valueFloat FLOAT , scaleTest NUMERIC(10," + scale + ")  );";
    String insert="insert into DecimalNumbers values (1.5, 20.55, 30.666);";
    String select="select * from DecimalNumbers;";
    Statement st=conn.createStatement();
    st.executeUpdate(createTable);
    st.executeUpdate(insert);
    rs=st.executeQuery(select);
    ResultSetMetaData rsmd2=rs.getMetaData();
    assertNotNull(rsmd2);
    assertEquals(scale,rsmd2.getScale(3));
    assertTrue(rsmd2.getScale(1) > 0);
    assertTrue(rsmd2.getScale(2) > 0);
    try {
      rsmd.getScale(0);
      fail("SQLException is not thrown");
    }
 catch (    SQLException e) {
    }
    try {
      rsmd.getScale(5);
      fail("SQLException is not thrown");
    }
 catch (    SQLException e) {
    }
    try {
      conn.close();
      rsmd.getScale(1);
      fail("Exception expected");
    }
 catch (    SQLException e) {
    }
  }
  finally {
    st.cancel();
  }
}

public void testGetScale ( ) throws SQLException { try { int scale = 3 ; String createTable = "create table DecimalNumbers ( valueDouble DOUBLE," + "valueFloat FLOAT , scaleTest NUMERIC(10," + scale + ")  );" ; String insert = "insert into DecimalNumbers values (1.5, 20.55, 30.666);" ; String select = "select * from DecimalNumbers;" ; Statement st = conn . createStatement ( ) ; st . executeUpdate ( createTable ) ; st . executeUpdate ( insert ) ; rs = st . executeQuery ( select ) ; ResultSetMetaData rsmd2 = rs . getMetaData ( ) ; assertNotNull ( rsmd2 ) ; assertEquals ( scale , rsmd2 . getScale ( 3 ) ) ; assertTrue ( rsmd2 . getScale ( 1 ) > 0 ) ; assertTrue ( rsmd2 . getScale ( 2 ) > 0 ) ; try { rsmd . getScale ( 0 ) ; fail ( "SQLException is not thrown" ) ; } catch ( SQLException e ) { } try { rsmd . getScale ( 5 ) ; fail ( "SQLException is not thrown" ) ; } catch ( SQLException e ) { } try { conn . close ( ) ; rsmd . getScale ( 1 ) ; fail ( "Exception expected" ) ; } catch ( SQLException e ) { } } finally { st . cancel ( ) ; } }
always returns 0 , exception tests fail no positive test case for black - box test possible : no default value indicated . not supported
