public RowMetaInterface getQueryFieldsFromPreparedStatement( String sql ) throws Exception {
    try ( PreparedStatement preparedStatement = connection
      .prepareStatement( databaseMeta.stripCR( sql ), ResultSet.TYPE_FORWARD_ONLY,
        ResultSet.CONCUR_READ_ONLY ) ) {
      preparedStatement.setMaxRows( 1 );
      ResultSetMetaData rsmd = preparedStatement.getMetaData();
      return getRowInfo( rsmd, false, false );
    } catch ( Exception e ) {
      throw new Exception( e );
    }
  }
@Test
  public void testGetQueryFieldsFromPreparedStatement() throws Exception {
    when( rsMetaData.getColumnCount() ).thenReturn( 1 );
    when( rsMetaData.getColumnName( 1 ) ).thenReturn( columnName );
    when( rsMetaData.getColumnLabel( 1 ) ).thenReturn( columnName );
    when( rsMetaData.getColumnType( 1 ) ).thenReturn( Types.DECIMAL );

    when( meta.stripCR( anyString() ) ).thenReturn( sql );
    when( meta.getDatabaseInterface() ).thenReturn( new MySQLDatabaseMeta() );
    when( conn.prepareStatement( sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY ) ).thenReturn( ps );
    when( ps.getMetaData() ).thenReturn( rsMetaData );

    Database db = new Database( log, meta );
    db.setConnection( conn );
    RowMetaInterface rowMetaInterface = db.getQueryFieldsFromPreparedStatement( sql );

    assertEquals( rowMetaInterface.size(), 1 );
    assertEquals( rowMetaInterface.getValueMeta( 0 ).getName(), columnName );
    assertTrue( rowMetaInterface.getValueMeta( 0 ) instanceof ValueMetaNumber );
  }