Java Code Examples for java.sql.Types#DOUBLE
The following examples show how to use
java.sql.Types#DOUBLE .
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: ApplyMasking.java From egeria with Apache License 2.0 | 6 votes |
private static void customMasking(DataValueDescriptor dataValueDescriptor, Properties properties) throws StandardException, ParseException { int jdbcType = TypeId.getBuiltInTypeId(dataValueDescriptor.getTypeName()).getJDBCTypeId(); switch (jdbcType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.CLOB: dataValueDescriptor.setValue(getCharMaskingValue(properties)); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: dataValueDescriptor.setValue(getDateMaskingValue(properties)); break; case Types.INTEGER: case Types.DOUBLE: case Types.DECIMAL: case Types.FLOAT: dataValueDescriptor.setValue(getIntMaskingValue(properties)); break; default: dataValueDescriptor.setValue("Masked"); } }
Example 2
Source File: PreparedStatement.java From r-course with MIT License | 6 votes |
public Object getObject(int parameterIndex) throws SQLException { checkBounds(parameterIndex, 0); if (this.parameterIsNull[parameterIndex - 1]) { return null; } // we can't rely on the default mapping for JDBC's ResultSet.getObject() for numerics, they're not one-to-one with PreparedStatement.setObject switch (PreparedStatement.this.parameterTypes[parameterIndex - 1]) { case Types.TINYINT: return Byte.valueOf(getByte(parameterIndex)); case Types.SMALLINT: return Short.valueOf(getShort(parameterIndex)); case Types.INTEGER: return Integer.valueOf(getInt(parameterIndex)); case Types.BIGINT: return Long.valueOf(getLong(parameterIndex)); case Types.FLOAT: return Float.valueOf(getFloat(parameterIndex)); case Types.DOUBLE: return Double.valueOf(getDouble(parameterIndex)); default: return this.bindingsAsRs.getObject(parameterIndex); } }
Example 3
Source File: MSSQLSpecific2005.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
@Override public int jetelType2sql(DataFieldMetadata field) { switch (field.getType()) { case DataFieldMetadata.DATE_FIELD: return Types.TIMESTAMP; case DataFieldMetadata.BOOLEAN_FIELD: return Types.BIT; case DataFieldMetadata.NUMERIC_FIELD: return Types.DOUBLE; default: return super.jetelType2sql(field); } }
Example 4
Source File: InformixSpecific.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
@Override public String jetelType2sqlDDL(DataFieldMetadata field) { int type = jetelType2sql(field); switch (type) { case Types.BINARY: case Types.VARBINARY: return sqlType2str(type); case Types.DOUBLE: return "FLOAT"; } return super.jetelType2sqlDDL(field); }
Example 5
Source File: ResultSetUtil.java From tajo with Apache License 2.0 | 5 votes |
public static int columnScale(int columnType) throws SQLException { switch (columnType) { case Types.BOOLEAN: case Types.CHAR: case Types.VARCHAR: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.DATE: case Types.BIT: case Types.BLOB: case Types.BINARY: case Types.ARRAY: case Types.STRUCT: case Types.NULL: return 0; case Types.FLOAT: return 7; case Types.DOUBLE: return 15; case Types.TIME: case Types.TIMESTAMP: return 9; case Types.DECIMAL: return Integer.MAX_VALUE; default: throw new SQLException("Invalid column type: " + columnType); } }
Example 6
Source File: DBTablePrinter.java From salesforce-jdbc with MIT License | 5 votes |
/** * Takes a generic SQL type and returns the category this type * belongs to. Types are categorized according to print formatting * needs: * <p> * Integers should not be truncated so column widths should * be adjusted without a column width limit. Text columns should be * left justified and can be truncated to a max. column width etc...</p> * <p> * See also: <a target="_blank" * href="http://docs.oracle.com/javase/8/docs/api/java/sql/Types.html"> * java.sql.Types</a> * * @param type Generic SQL type * @return The category this type belongs to */ private static int whichCategory(int type) { switch (type) { case Types.BIGINT: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: return CATEGORY_INTEGER; case Types.REAL: case Types.DOUBLE: case Types.DECIMAL: return CATEGORY_DOUBLE; case Types.DATE: case Types.TIME: case Types.TIME_WITH_TIMEZONE: case Types.TIMESTAMP: case Types.TIMESTAMP_WITH_TIMEZONE: return CATEGORY_DATETIME; case Types.BOOLEAN: return CATEGORY_BOOLEAN; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: case Types.LONGNVARCHAR: case Types.CHAR: case Types.NCHAR: return CATEGORY_STRING; default: return CATEGORY_OTHER; } }
Example 7
Source File: MongoData.java From Mycat2 with GNU General Public License v3.0 | 5 votes |
public static int getObjectToType(Object ob){ if (ob instanceof Integer) { return Types.INTEGER; } else if (ob instanceof Boolean) { return Types.BOOLEAN; } else if (ob instanceof Byte) { return Types.BIT; } else if (ob instanceof Short) { return Types.INTEGER; } else if (ob instanceof Float) { return Types.FLOAT; } else if (ob instanceof Long) { return Types.BIGINT; } else if (ob instanceof Double) { return Types.DOUBLE; } else if (ob instanceof Date) { return Types.DATE; } else if (ob instanceof Time) { return Types.TIME; } else if (ob instanceof Timestamp) { return Types.TIMESTAMP; } else if (ob instanceof String) { return Types.VARCHAR; } else { return Types.VARCHAR; } }
Example 8
Source File: UnaryArithmeticParameterTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** * Tests SQRT with unary minus and unary plus * @throws Exception */ public void testSQRTWithUnaryMinusAndPlus() throws Exception{ PreparedStatement ps = prepareStatement("select sqrt(-?) from t1"); ps.setInt(1,-64); int[] expectedTypes= new int[]{Types.DOUBLE}; JDBC.assertParameterTypes(ps,expectedTypes); Object[][] expectedRows = new Object[][]{{new String("8.0")},{new String("8.0")}}; JDBC.assertFullResultSet(ps.executeQuery(), expectedRows, true); ps.close(); }
Example 9
Source File: JDBCAdapter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public Class<?> getColumnClass(int column) { int type; try { type = metaData.getColumnType(column + 1); } catch (SQLException e) { return super.getColumnClass(column); } switch (type) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: return String.class; case Types.BIT: return Boolean.class; case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: return Integer.class; case Types.BIGINT: return Long.class; case Types.FLOAT: case Types.DOUBLE: return Double.class; case Types.DATE: return java.sql.Date.class; default: return Object.class; } }
Example 10
Source File: JdbcTypeConverterTest.java From Alink with Apache License 2.0 | 5 votes |
@Test public void testMutualConversion() { int[] types = new int[]{ Types.VARCHAR, Types.BOOLEAN, Types.TINYINT, Types.SMALLINT, Types.INTEGER, Types.BIGINT, Types.FLOAT, Types.DOUBLE, Types.DATE, Types.TIME, Types.TIMESTAMP, Types.DECIMAL, Types.BINARY}; for (int type : types) { TypeInformation<?> flinkType = JdbcTypeConverter.getFlinkType(type); int sqlType = JdbcTypeConverter.getIntegerSqlType(flinkType); Assert.assertEquals(type, sqlType); } }
Example 11
Source File: UnaryArithmeticParameterTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Tests MAX function with Unary plus and Unary minus * @throws SQLException */ public void testMAXWithUnaryMinusAndPlus() throws SQLException{ Statement s = createStatement(); s.execute("CREATE FUNCTION MAX_CNI(P1 INT, P2 INT) RETURNS INT CALLED ON NULL INPUT EXTERNAL NAME 'java.lang.Math.max' LANGUAGE JAVA PARAMETER STYLE JAVA"); PreparedStatement ps = prepareStatement("select * from t1 where -? = max_cni(-5,-1)"); try { ps.setInt(1,1); int[] expectedTypes= new int[]{Types.INTEGER}; JDBC.assertParameterTypes(ps,expectedTypes); Object[][] expectedRows = new Object[][]{{new Integer(1),new Integer(1),new Double(1.1),new String("abc")}, {new Integer(-1),new Integer(-1),new Double(-1.0),new String("def")}}; JDBC.assertUnorderedResultSet(ps.executeQuery(), expectedRows, false); ps = prepareStatement("select * from t1 where -? = max_cni(-?,+?)"); ps.setInt(1,-1); ps.setInt(2,1); ps.setInt(3,1); expectedTypes= new int[]{Types.INTEGER,Types.INTEGER,Types.INTEGER}; JDBC.assertParameterTypes(ps,expectedTypes); JDBC.assertUnorderedResultSet(ps.executeQuery(), expectedRows, false); //Try the function again. But use, use sqrt(+?) & abs(-?) functions to send params ps = prepareStatement("select * from t1 where -? = max_cni(abs(-?), sqrt(+?))"); ps.setInt(1,-2); ps.setInt(2,1); ps.setInt(3,4); expectedTypes=new int[]{Types.INTEGER,Types.DOUBLE,Types.DOUBLE}; JDBC.assertParameterTypes(ps,expectedTypes); JDBC.assertUnorderedResultSet(ps.executeQuery(), expectedRows, false); } finally { ps.close(); s.execute("Drop function MAX_CNI" ); s.close(); } }
Example 12
Source File: DataTypeUtilities.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Is the data type signed. * * @param dtd * data type descriptor */ public static boolean isSigned(DataTypeDescriptor dtd) { int typeId = dtd.getTypeId().getJDBCTypeId(); return (typeId == Types.INTEGER || typeId == Types.FLOAT || typeId == Types.DECIMAL || typeId == Types.SMALLINT || typeId == Types.BIGINT || typeId == Types.TINYINT || typeId == Types.NUMERIC || typeId == Types.REAL || typeId == Types.DOUBLE); }
Example 13
Source File: JDBCAdapter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public Class<?> getColumnClass(int column) { int type; try { type = metaData.getColumnType(column + 1); } catch (SQLException e) { return super.getColumnClass(column); } switch (type) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: return String.class; case Types.BIT: return Boolean.class; case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: return Integer.class; case Types.BIGINT: return Long.class; case Types.FLOAT: case Types.DOUBLE: return Double.class; case Types.DATE: return java.sql.Date.class; default: return Object.class; } }
Example 14
Source File: ResultSetMetaData.java From birt with Eclipse Public License 1.0 | 4 votes |
public int getColumnType( int index ) throws OdaException { logger.logp( java.util.logging.Level.FINEST, ResultSetMetaData.class.getName( ), "getColumnType", "ResultSetMetaData.getColumnType( )" ); assertNotNull( rsMetadata ); try { int reType = getColumnTypeForSpecialJDBCDriver( index ); if ( reType != Types.OTHER ) return reType; reType = rsMetadata.getColumnType( index ); if ( reType == Types.DECIMAL ) { int scale = rsMetadata.getScale( index ); int precision = rsMetadata.getPrecision( index ); if ( ( scale == 0 ) && ( precision > 0 ) && ( precision <= 9 ) ) { reType = Types.INTEGER; } else if ( precision > 9 && precision <= 15 ) { reType = Types.DOUBLE; } else if ( precision > 15 ) { reType = Types.DECIMAL; } } /* redirect the call to JDBC ResultSetMetaData.getColumnType(int) */ return reType; } catch ( SQLException e ) { throw new JDBCException( ResourceConstants.COLUMN_TYPE_CANNOT_GET, e ); } }
Example 15
Source File: DefaultAdaptor.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
/** * By default, we accord to Hive's type system for this converting. * @param sourceTypeId Column type id from Source * @return The column type name supported by Kylin. */ @Override public String toKylinTypeName(int sourceTypeId) { String result = "any"; switch (sourceTypeId) { case Types.CHAR: result = "char"; break; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: result = "varchar"; break; case Types.NUMERIC: case Types.DECIMAL: result = "decimal"; break; case Types.BIT: case Types.BOOLEAN: result = "boolean"; break; case Types.TINYINT: result = "tinyint"; break; case Types.SMALLINT: result = "smallint"; break; case Types.INTEGER: result = "integer"; break; case Types.BIGINT: result = "bigint"; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = "double"; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = "byte"; break; case Types.DATE: result = "date"; break; case Types.TIME: result = "time"; break; case Types.TIMESTAMP: result = "timestamp"; break; default: //do nothing break; } return result; }
Example 16
Source File: TypesTranslator.java From sql-layer with GNU Affero General Public License v3.0 | 4 votes |
public Class<?> jdbcClass(TInstance type) { TClass tclass = TInstance.tClass(type); if (tclass == null) return Object.class; int jdbcType = tclass.jdbcType(); switch (jdbcType) { case Types.DECIMAL: case Types.NUMERIC: return BigDecimal.class; case Types.BOOLEAN: return Boolean.class; case Types.TINYINT: return Byte.class; case Types.BINARY: case Types.BIT: case Types.LONGVARBINARY: case Types.VARBINARY: case Types.BLOB: return byte[].class; case Types.DATE: return java.sql.Date.class; case Types.DOUBLE: return Double.class; case Types.FLOAT: case Types.REAL: return Float.class; case Types.INTEGER: return Integer.class; case Types.BIGINT: return Long.class; case Types.SMALLINT: return Short.class; case Types.CHAR: case Types.LONGNVARCHAR: case Types.LONGVARCHAR: case Types.NCHAR: case Types.NVARCHAR: case Types.VARCHAR: case Types.CLOB: return String.class; case Types.TIME: return java.sql.Time.class; case Types.TIMESTAMP: return java.sql.Timestamp.class; /* case Types.ARRAY: return java.sql.Array.class; case Types.BLOB: return java.sql.Blob.class; case Types.CLOB: return java.sql.Clob.class; case Types.NCLOB: return java.sql.NClob.class; case Types.REF: return java.sql.Ref.class; case Types.ROWID: return java.sql.RowId.class; case Types.SQLXML: return java.sql.SQLXML.class; */ case Types.NULL: case Types.DATALINK: case Types.DISTINCT: case Types.JAVA_OBJECT: case Types.OTHER: case Types.STRUCT: default: break; } if (tclass == AkResultSet.INSTANCE) return java.sql.ResultSet.class; return Object.class; }
Example 17
Source File: DB2LengthOperatorNode.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
private int getConstantLength( ) throws StandardException { DataTypeDescriptor typeDescriptor = operand.getTypeServices(); switch( typeDescriptor.getJDBCTypeId()) { case Types.BIGINT: return 8; case Types.BOOLEAN: case Types.BIT: return 1; case Types.BINARY: case Types.CHAR: return typeDescriptor.getMaximumWidth(); case Types.DATE: return 4; case Types.DECIMAL: case Types.NUMERIC: return typeDescriptor.getPrecision()/2 + 1; case Types.DOUBLE: return 8; case Types.FLOAT: case Types.REAL: case Types.INTEGER: return 4; case Types.SMALLINT: return 2; case Types.TIME: return 3; case Types.TIMESTAMP: return 10; case Types.TINYINT: return 1; case Types.LONGVARCHAR: case Types.VARCHAR: case Types.LONGVARBINARY: case Types.VARBINARY: case Types.BLOB: return getConstantNodeLength(); default: return -1; } }
Example 18
Source File: UpdatableResultSet.java From Komondor with GNU General Public License v3.0 | 4 votes |
private void setParamValue(PreparedStatement ps, int psIdx, ResultSetRow row, int rsIdx, int sqlType) throws SQLException { byte[] val = row.getColumnValue(rsIdx); if (val == null) { ps.setNull(psIdx, Types.NULL); return; } switch (sqlType) { case Types.NULL: ps.setNull(psIdx, Types.NULL); break; case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: ps.setInt(psIdx, row.getInt(rsIdx)); break; case Types.BIGINT: ps.setLong(psIdx, row.getLong(rsIdx)); break; case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.DECIMAL: case Types.NUMERIC: ps.setString(psIdx, row.getString(rsIdx, this.charEncoding, this.connection)); break; case Types.DATE: ps.setDate(psIdx, row.getDateFast(rsIdx, this.connection, this, this.fastDefaultCal), this.fastDefaultCal); break; case Types.TIMESTAMP: ps.setTimestamp(psIdx, row.getTimestampFast(rsIdx, this.fastDefaultCal, this.connection.getDefaultTimeZone(), false, this.connection, this)); break; case Types.TIME: ps.setTime(psIdx, row.getTimeFast(rsIdx, this.fastDefaultCal, this.connection.getDefaultTimeZone(), false, this.connection, this)); break; case Types.FLOAT: case Types.DOUBLE: case Types.REAL: case Types.BOOLEAN: ps.setBytesNoEscapeNoQuotes(psIdx, val); break; /* * default, but also explicitly for following types: * case Types.BINARY: * case Types.BLOB: */ default: ps.setBytes(psIdx, val); break; } }
Example 19
Source File: AvaticaSite.java From calcite-avatica with Apache License 2.0 | 4 votes |
/** Similar logic to {@link #setObject}. */ public static Object get(Cursor.Accessor accessor, int targetSqlType, Calendar localCalendar) throws SQLException { switch (targetSqlType) { case Types.CLOB: case Types.DATALINK: case Types.NCLOB: case Types.REF: case Types.SQLXML: throw notImplemented(); case Types.STRUCT: return accessor.getStruct(); case Types.ARRAY: return accessor.getArray(); case Types.BIGINT: final long aLong = accessor.getLong(); if (aLong == 0 && accessor.wasNull()) { return null; } return aLong; case Types.BINARY: case Types.LONGVARBINARY: case Types.VARBINARY: return accessor.getBytes(); case Types.BIT: case Types.BOOLEAN: final boolean aBoolean = accessor.getBoolean(); if (!aBoolean && accessor.wasNull()) { return null; } return aBoolean; case Types.BLOB: return accessor.getBlob(); case Types.DATE: return accessor.getDate(localCalendar); case Types.DECIMAL: case Types.NUMERIC: return accessor.getBigDecimal(); case Types.DISTINCT: throw notImplemented(); case Types.DOUBLE: case Types.FLOAT: // yes really; SQL FLOAT is up to 8 bytes final double aDouble = accessor.getDouble(); if (aDouble == 0 && accessor.wasNull()) { return null; } return aDouble; case Types.INTEGER: final int anInt = accessor.getInt(); if (anInt == 0 && accessor.wasNull()) { return null; } return anInt; case Types.JAVA_OBJECT: case Types.OTHER: return accessor.getObject(); case Types.LONGNVARCHAR: case Types.LONGVARCHAR: case Types.NVARCHAR: case Types.VARCHAR: case Types.CHAR: case Types.NCHAR: return accessor.getString(); case Types.REAL: final float aFloat = accessor.getFloat(); if (aFloat == 0 && accessor.wasNull()) { return null; } return aFloat; case Types.ROWID: throw notImplemented(); case Types.SMALLINT: final short aShort = accessor.getShort(); if (aShort == 0 && accessor.wasNull()) { return null; } return aShort; case Types.TIME: return accessor.getTime(localCalendar); case Types.TIMESTAMP: return accessor.getTimestamp(localCalendar); case Types.TINYINT: final byte aByte = accessor.getByte(); if (aByte == 0 && accessor.wasNull()) { return null; } return aByte; default: throw notImplemented(); } }
Example 20
Source File: JavaSqlConversion.java From aceql-http with GNU Lesser General Public License v2.1 | 4 votes |
public static String fromJavaToSql(int javaType) { String sqlType = null; if (javaType == Types.CHAR) { sqlType = AceQLTypes.CHAR; } else if (javaType == Types.VARCHAR) { sqlType = AceQLTypes.VARCHAR; } else if (javaType == Types.LONGVARCHAR) { sqlType = AceQLTypes.LONGVARCHAR; } else if (javaType == Types.NUMERIC) { sqlType = AceQLTypes.NUMERIC; } else if (javaType == Types.BIT) { sqlType = AceQLTypes.BIT; } else if (javaType == Types.NUMERIC) { sqlType = AceQLTypes.NUMERIC; } else if (javaType == Types.DECIMAL) { sqlType = AceQLTypes.DECIMAL; } else if (javaType == Types.TINYINT) { sqlType = AceQLTypes.TINYINT; } else if (javaType == Types.SMALLINT) { sqlType = AceQLTypes.SMALLINT; } else if (javaType == Types.INTEGER) { sqlType = AceQLTypes.INTEGER; } else if (javaType == Types.BIGINT) { sqlType = AceQLTypes.BIGINT; } else if (javaType == Types.REAL) { sqlType = AceQLTypes.REAL; } else if (javaType == Types.FLOAT) { sqlType = AceQLTypes.FLOAT; } else if (javaType == Types.DOUBLE) { sqlType = AceQLTypes.DOUBLE_PRECISION; } else if (javaType == Types.DATE) { sqlType = AceQLTypes.DATE; } else if (javaType == Types.TIME) { sqlType = AceQLTypes.TIME; } else if (javaType == Types.TIMESTAMP) { sqlType = AceQLTypes.TIMESTAMP; } else if (javaType == Types.BINARY) { sqlType = AceQLTypes.BINARY; } else if (javaType == Types.VARBINARY) { sqlType = AceQLTypes.VARBINARY; } else if (javaType == Types.LONGVARBINARY) { sqlType = AceQLTypes.LONGVARBINARY; } else if (javaType == Types.BLOB) { sqlType = AceQLTypes.BLOB; } else if (javaType == Types.CLOB) { sqlType = AceQLTypes.CLOB; } else { return "UNKNOWN"; } return sqlType; }