Java Code Examples for java.sql.ResultSetMetaData#isCurrency()
The following examples show how to use
java.sql.ResultSetMetaData#isCurrency() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreparedStatementTest.java From dremio-oss with Apache License 2.0 | 6 votes |
boolean isEqualsTo(ResultSetMetaData metadata, int colNum) throws SQLException { return metadata.getCatalogName(colNum).equals(InfoSchemaConstants.IS_CATALOG_NAME) && metadata.getSchemaName(colNum).isEmpty() && metadata.getTableName(colNum).isEmpty() && metadata.getColumnName(colNum).equals(columnName) && metadata.getColumnLabel(colNum).equals(columnName) && metadata.getColumnType(colNum) == type && metadata.isNullable(colNum) == nullable && // There is an existing bug where query results doesn't contain the precision for VARCHAR field. //metadata.getPrecision(colNum) == precision && metadata.getScale(colNum) == scale && metadata.isSigned(colNum) == signed && metadata.getColumnDisplaySize(colNum) == displaySize && metadata.getColumnClassName(colNum).equals(className) && metadata.isSearchable(colNum) && metadata.isAutoIncrement(colNum) == false && metadata.isCaseSensitive(colNum) == false && metadata.isReadOnly(colNum) && metadata.isWritable(colNum) == false && metadata.isDefinitelyWritable(colNum) == false && metadata.isCurrency(colNum) == false; }
Example 2
Source File: SelectStatementsTester.java From spanner-jdbc with MIT License | 5 votes |
private void testSelect(String sql, Object... parameters) throws SQLException { PreparedStatement ps = connection.prepareStatement(sql); for (int i = 1; i <= parameters.length; i++) { ps.setObject(i, parameters[i - 1]); } try (ResultSet rs = ps.executeQuery()) { ResultSetMetaData metadata = rs.getMetaData(); for (int i = 1; i <= metadata.getColumnCount(); i++) { metadata.getColumnClassName(i); metadata.getColumnDisplaySize(i); metadata.getColumnLabel(i); metadata.getColumnName(i); metadata.getColumnType(i); metadata.getColumnTypeName(i); metadata.getPrecision(i); metadata.getScale(i); metadata.getCatalogName(i); metadata.getSchemaName(i); metadata.getTableName(i); metadata.isNullable(i); metadata.isAutoIncrement(i); metadata.isCaseSensitive(i); metadata.isCurrency(i); metadata.isDefinitelyWritable(i); metadata.isReadOnly(i); metadata.isSearchable(i); metadata.isSigned(i); metadata.isWritable(i); } while (rs.next()) { // do nothing } } }
Example 3
Source File: ResultSetLiveTest.java From tutorials with MIT License | 5 votes |
@Test public void givenDbConnectionF_whenRSMetaInfo_thenCorrect() throws SQLException { int columnCount = 0; try (PreparedStatement pstmt = dbConnection.prepareStatement("select * from employees", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = pstmt.executeQuery()) { ResultSetMetaData metaData = rs.getMetaData(); columnCount = metaData.getColumnCount(); for (int i = 1; i <= columnCount; i++) { String catalogName = metaData.getCatalogName(i); String className = metaData.getColumnClassName(i); String label = metaData.getColumnLabel(i); String name = metaData.getColumnName(i); String typeName = metaData.getColumnTypeName(i); Integer type = metaData.getColumnType(i); String tableName = metaData.getTableName(i); String schemaName = metaData.getSchemaName(i); boolean isAutoIncrement = metaData.isAutoIncrement(i); boolean isCaseSensitive = metaData.isCaseSensitive(i); boolean isCurrency = metaData.isCurrency(i); boolean isDefiniteWritable = metaData.isDefinitelyWritable(i); boolean isReadOnly = metaData.isReadOnly(i); boolean isSearchable = metaData.isSearchable(i); boolean isReadable = metaData.isReadOnly(i); boolean isSigned = metaData.isSigned(i); boolean isWritable = metaData.isWritable(i); int nullable = metaData.isNullable(i); } } assertEquals("column count", 4, columnCount); }
Example 4
Source File: ResultSetTableModelFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * No longer used. * * @param rsmd * @param metaData * @param column */ @Deprecated public static void updateMetaData( final ResultSetMetaData rsmd, final DefaultTableMetaData metaData, final int column ) { try { if ( rsmd.isCurrency( column + 1 ) ) { metaData.setColumnAttribute( column, MetaAttributeNames.Numeric.NAMESPACE, MetaAttributeNames.Numeric.CURRENCY, Boolean.TRUE ); } else { metaData.setColumnAttribute( column, MetaAttributeNames.Numeric.NAMESPACE, MetaAttributeNames.Numeric.CURRENCY, Boolean.FALSE ); } if ( rsmd.isSigned( column + 1 ) ) { metaData.setColumnAttribute( column, MetaAttributeNames.Numeric.NAMESPACE, MetaAttributeNames.Numeric.SIGNED, Boolean.TRUE ); } else { metaData.setColumnAttribute( column, MetaAttributeNames.Numeric.NAMESPACE, MetaAttributeNames.Numeric.SIGNED, Boolean.FALSE ); } final String tableName = rsmd.getTableName( column + 1 ); if ( tableName != null ) { metaData.setColumnAttribute( column, MetaAttributeNames.Database.NAMESPACE, MetaAttributeNames.Database.TABLE, tableName ); } final String schemaName = rsmd.getSchemaName( column + 1 ); if ( schemaName != null ) { metaData.setColumnAttribute( column, MetaAttributeNames.Database.NAMESPACE, MetaAttributeNames.Database.SCHEMA, schemaName ); } final String catalogName = rsmd.getCatalogName( column + 1 ); if ( catalogName != null ) { metaData.setColumnAttribute( column, MetaAttributeNames.Database.NAMESPACE, MetaAttributeNames.Database.CATALOG, catalogName ); } final String label = rsmd.getColumnLabel( column + 1 ); if ( label != null ) { metaData.setColumnAttribute( column, MetaAttributeNames.Formatting.NAMESPACE, MetaAttributeNames.Formatting.LABEL, label ); } final int displaySize = rsmd.getColumnDisplaySize( column + 1 ); metaData.setColumnAttribute( column, MetaAttributeNames.Formatting.NAMESPACE, MetaAttributeNames.Formatting.DISPLAY_SIZE, IntegerCache.getInteger( displaySize ) ); final int precision = rsmd.getPrecision( column + 1 ); metaData.setColumnAttribute( column, MetaAttributeNames.Numeric.NAMESPACE, MetaAttributeNames.Numeric.PRECISION, IntegerCache.getInteger( precision ) ); final int scale = rsmd.getScale( column + 1 ); metaData.setColumnAttribute( column, MetaAttributeNames.Numeric.NAMESPACE, MetaAttributeNames.Numeric.SCALE, IntegerCache.getInteger( scale ) ); } catch ( SQLException sqle ) { // It is non-fatal if the meta-data cannot be read from the result set. Drivers are // buggy all the time .. } }