List of usage examples for java.sql Types DOUBLE
int DOUBLE
To view the source code for java.sql Types DOUBLE.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type DOUBLE
.
From source file:org.apache.openjpa.jdbc.schema.Schemas.java
/** * Return the SQL type name for the given {@link Types} constant. *///from ww w . j a v a2s .co m public static String getJDBCName(int type) { switch (type) { case Types.ARRAY: return "array"; case Types.BIGINT: return "bigint"; case Types.BINARY: return "binary"; case Types.BIT: return "bit"; case Types.BLOB: return "blob"; case Types.CHAR: return "char"; case Types.CLOB: return "clob"; case Types.DATE: return "date"; case Types.DECIMAL: return "decimal"; case Types.DISTINCT: return "distinct"; case Types.DOUBLE: return "double"; case Types.FLOAT: return "float"; case Types.INTEGER: return "integer"; case Types.JAVA_OBJECT: return "java_object"; case Types.LONGVARBINARY: return "longvarbinary"; case Types.LONGVARCHAR: return "longvarchar"; case Types.NULL: return "null"; case Types.NUMERIC: return "numeric"; case Types.OTHER: return "other"; case Types.REAL: return "real"; case Types.REF: return "ref"; case Types.SMALLINT: return "smallint"; case Types.STRUCT: return "struct"; case Types.TIME: return "time"; case Types.TIMESTAMP: return "timestamp"; case Types.TINYINT: return "tinyint"; case Types.VARBINARY: return "varbinary"; case Types.VARCHAR: return "varchar"; default: return "unknown(" + type + ")"; } }
From source file:com.redsqirl.workflow.utils.jdbc.GenericConfFile.java
public GenericConfFile(String name, Connection conn) throws SQLException { dictionaryName = name;//from w w w. j a va2 s .c o m databaseMetaData = conn.getMetaData(); typeRecognized = new LinkedHashMap<Integer, FieldType>(); typeRecognized.put(Types.BOOLEAN, FieldType.BOOLEAN); typeRecognized.put(Types.DATE, FieldType.DATETIME); typeRecognized.put(Types.TIME, FieldType.DATETIME); typeRecognized.put(Types.DOUBLE, FieldType.DOUBLE); typeRecognized.put(Types.NUMERIC, FieldType.DOUBLE); typeRecognized.put(Types.DECIMAL, FieldType.DOUBLE); typeRecognized.put(Types.REAL, FieldType.DOUBLE); typeRecognized.put(Types.FLOAT, FieldType.FLOAT); typeRecognized.put(Types.INTEGER, FieldType.INT); typeRecognized.put(Types.SMALLINT, FieldType.INT); typeRecognized.put(Types.TINYINT, FieldType.INT); typeRecognized.put(Types.BIGINT, FieldType.LONG); typeRecognized.put(Types.VARCHAR, FieldType.STRING); typeRecognized.put(Types.CHAR, FieldType.STRING); typeRecognized.put(Types.LONGVARCHAR, FieldType.STRING); typeRecognized.put(Types.NVARCHAR, FieldType.STRING); typeRecognized.put(Types.NCHAR, FieldType.STRING); typeRecognized.put(Types.LONGNVARCHAR, FieldType.STRING); typeRecognized.put(Types.TIMESTAMP, FieldType.TIMESTAMP); }
From source file:konditer.client.dao.OrdereDao.java
@Override public void addOrdere(int orderId, int customerId, int orderStatusId, int deliveryId, Date orderDateIncome, Date orderDateEnd, double orderCakePrice, double orderDeliveryPrice, double orderWeight, String orderInsidesId, String orderInfo) { String SQL_QUERY = "INSERT INTO orders ( ORDER_ID, " + "CUSTOMER_ID, " + "ORDER_STATUS_ID, " + "DELIVERY_ID, " + "ORDER_DATE_INCOME, " + "ORDER_DATE_END, " + "ORDER_CAKE_PRICE, " + "ORDER_DELIVERY_PRICE, " + "ORDER_WEIGHT, " + "ORDER_INSIDES_ID, " + "ORDER_INFO ) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?)"; int rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { orderId, customerId, orderStatusId, deliveryId, orderDateIncome, orderDateEnd, orderCakePrice, orderDeliveryPrice, orderWeight, orderInsidesId, orderInfo }, new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP, Types.DOUBLE, Types.DOUBLE, Types.DOUBLE, Types.VARCHAR, Types.VARCHAR }); Logger.getLogger(CakeDao.class.getName()).log(Level.SEVERE, " : {0} .", rowCount);//from w ww .j a v a 2 s . c o m System.out.println(ordereDao.getOrdere(orderId).toString()); }
From source file:com.trackplus.ddl.GenericStringValueConverter.java
protected String extractColumnValue(ResultSet resultSet, int columnIdx, int jdbcType) throws SQLException, DDLException { String value = resultSet.getString(columnIdx); if (value != null) { switch (jdbcType) { case Types.NUMERIC: case Types.DECIMAL: break; case Types.BIT: case Types.BOOLEAN: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.REAL: case Types.FLOAT: case Types.DOUBLE: { break; }//from ww w . j a v a2 s . c o m case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: case Types.BINARY: case Types.VARBINARY: case Types.TIME: case Types.CLOB: case Types.ARRAY: case Types.REF: { value = "'" + value.replaceAll("'", "''") + "'"; break; } case Types.DATE: case Types.TIMESTAMP: { Date d = resultSet.getDate(columnIdx); Calendar cal = Calendar.getInstance(); cal.setTime(d); int year = cal.get(Calendar.YEAR); if (year < 1900) { throw new DDLException("Invalid date:" + d); } else { value = "'" + value + "'"; } break; } case Types.BLOB: case Types.LONGVARBINARY: { Blob blobValue = resultSet.getBlob(columnIdx); String str = new String(Base64.encodeBase64(blobValue.getBytes(1l, (int) blobValue.length()))); value = "'" + str + "'"; break; } default: break; } } return value; }
From source file:com.thinkbiganalytics.discovery.util.ParserHelper.java
public static String sqlTypeToHiveType(Integer type) { switch (type) { case Types.BIGINT: return "bigint"; case Types.NUMERIC: case Types.DOUBLE: case Types.DECIMAL: return "double"; case Types.INTEGER: return "int"; case Types.FLOAT: return "float"; case Types.TINYINT: return "tinyint"; case Types.DATE: return "date"; case Types.TIMESTAMP: return "timestamp"; case Types.BOOLEAN: return "boolean"; case Types.BINARY: return "binary"; default://from w w w.jav a2 s. co m return "string"; } }
From source file:com.streamsets.pipeline.stage.it.AllSdcTypesIT.java
@Parameterized.Parameters(name = "type({0})") public static Collection<Object[]> data() throws Exception { return Arrays.asList(new Object[][] { { Field.create(Field.Type.BOOLEAN, true), true, Types.BOOLEAN, true }, { Field.create(Field.Type.CHAR, 'A'), true, Types.VARCHAR, "A" }, { Field.create(Field.Type.BYTE, (byte) 0x00), false, 0, null }, { Field.create(Field.Type.SHORT, 10), true, Types.INTEGER, 10 }, { Field.create(Field.Type.INTEGER, 10), true, Types.INTEGER, 10 }, { Field.create(Field.Type.LONG, 10), true, Types.BIGINT, 10L }, { Field.create(Field.Type.FLOAT, 1.5), true, Types.FLOAT, 1.5 }, { Field.create(Field.Type.DOUBLE, 1.5), true, Types.DOUBLE, 1.5 }, { Field.create(Field.Type.DATE, new Date(116, 5, 13)), true, Types.DATE, new Date(116, 5, 13) }, { Field.create(Field.Type.DATETIME, date), true, Types.VARCHAR, datetimeFormat.format(date) }, { Field.create(Field.Type.TIME, date), true, Types.VARCHAR, timeFormat.format(date) }, { Field.create(Field.Type.DECIMAL, BigDecimal.valueOf(1.5)), true, Types.DECIMAL, new BigDecimal(BigInteger.valueOf(15), 1, new MathContext(2, RoundingMode.FLOOR)) }, { Field.create(Field.Type.STRING, "StreamSets"), true, Types.VARCHAR, "StreamSets" }, { Field.create(Field.Type.BYTE_ARRAY, new byte[] { (byte) 0x00 }), true, Types.BINARY, new byte[] { (byte) 0x00 } }, { Field.create(Field.Type.MAP, Collections.emptyMap()), false, 0, null }, { Field.create(Field.Type.LIST, Collections.emptyList()), false, 0, null }, { Field.create(Field.Type.LIST_MAP, new LinkedHashMap<>()), false, 0, null }, }); }
From source file:org.jpos.qi.system.SQLQueryObject.java
private boolean isNumericDataType(int type) { switch (type) { case Types.BIGINT: case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.INTEGER: case Types.NUMERIC: case Types.REAL: case Types.SMALLINT: case Types.TINYINT: return true; default://from ww w. java 2s .co m return false; } }
From source file:com.zousu.mongopresser.Presser.java
public void press() { //get a list of all the tables and columns logger.info("Starting MySQL to Mongo Conversion..."); logger.info("Preparing Tables..."); mySQLHandler.initialiseDatabase();/*from www .j av a 2 s . com*/ List<Table> tables = mySQLHandler.getTableList(); for (int i = 0; i < tables.size(); i++) { Table table = tables.get(i); List<Column> columns = table.getColumns(); List<DBObject> dboList = new ArrayList<DBObject>(); SqlRowSet rs = mySQLHandler.selectAllFromTable(table.getTableName()); logger.info("Creating objects for " + table.getTableName() + "..."); while (rs.next()) { BasicDBObject dbo = new BasicDBObject(); for (int j = 0; j < columns.size(); j++) { Column col = columns.get(j); String colName = col.getColumnName(); switch (col.getType()) { case Types.INTEGER: case Types.BIGINT: dbo.append(colName, rs.getInt(colName)); break; case Types.DOUBLE: dbo.append(colName, rs.getDouble(colName)); break; case Types.DATE: dbo.append(colName, rs.getDate(colName)); break; default: dbo.append(colName, rs.getString(colName)); break; } } dboList.add(dbo); } //now insert it logger.info("Inserting " + dboList.size() + " mongo rows into " + table.getTableName() + "..."); table.setNumOfRows(dboList.size()); try { mongoHandler.createCollection(table.getTableName(), true); mongoHandler.batchInsert(dboList, table.getTableName()); assert (mongoHandler.getNumObjectsInCollection(table.getTableName()) == dboList.size()); logger.info(table.getTableName() + " DONE!"); } catch (CollectionExistException e) { e.printStackTrace(); } } logger.info(tables.size() + " collections added!"); //now check go get it from mongo and check if the data there is correct logger.info("Checking mongo consistency..."); for (int i = 0; i < tables.size(); i++) { Table table = tables.get(i); assert (mongoHandler.getNumObjectsInCollection(table.getTableName()) == table.getNumOfRows()); logger.info(table.getTableName() + " consistent!"); } logger.info("MySQL to Mongo Conversion Completed!!!!"); }
From source file:konditer_reorganized_database.dao.CakeDao.java
@Override public void addCake(int cakeId, int customerId, double cakePrice, int orderId, String cakeName, double cakeWeight, String cakePhoto, String cakeKeywords, boolean cakeStatus) throws DataAccessException { String SQL_QUERY = "INSERT INTO cakes ( CAKE_ID, " + "CUSTOMER_ID, " + "CAKE_PRICE, " + "ORDER_ID, " + "CAKE_NAME, " + "CAKE_WEIGHT, " + "CAKE_PHOTO_MINI, " + "CAKE_PHOTO_MAXI, " + "CAKE_KEYWORDS, " + "CAKE_STATUS ) " + "VALUES (?,?,?,?,?,?,?,?,?,?)"; //int cakeId1 = genIdDao.getCakeId(); /*//from w w w. j a va 2s.c om ??? ??? 2- ? ?? ? */ //try{ int rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { cakeId, customerId, cakePrice, orderId, cakeName, cakeWeight, "" + cakeId + "_s.jpg", "" + cakeId + ".jpg", cakeKeywords, cakeStatus }, new int[] { Types.INTEGER, Types.INTEGER, Types.DOUBLE, Types.INTEGER, Types.VARCHAR, Types.DOUBLE, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN }); Logger.getLogger(CakeDao.class.getName()).log(Level.SEVERE, " : {0} .", rowCount); //}catch(DataAccessException e){ // Logger.getLogger(CakeDao.class.getName()).log(Level.SEVERE, ". ."); //genIdDao.decrementCakeId(); //} }
From source file:com.streamsets.pipeline.stage.it.AvroToParquetHiveIT.java
@Parameterized.Parameters(name = "type({0})") public static Collection<Object[]> data() throws Exception { return Arrays.asList(new Object[][] { // Primitive types { "\"boolean\"", true, true, "BOOLEAN", Types.BOOLEAN, "0" }, { "\"int\"", Integer.MIN_VALUE, Integer.MIN_VALUE, "INT", Types.INTEGER, "0" }, { "\"long\"", Long.MAX_VALUE, Long.MAX_VALUE, "BIGINT", Types.BIGINT, "0" }, // From some reason type is FLOAT, but returned object is double { "\"float\"", Float.NaN, Double.NaN, "FLOAT", Types.FLOAT, "0" }, { "\"double\"", Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, "DOUBLE", Types.DOUBLE, "0" }, { "\"bytes\"", ByteBuffer.wrap(new byte[] { (byte) 0x00, (byte) 0xFF }), new byte[] { (byte) 0x00, (byte) 0xFF }, "BINARY", Types.BINARY, "1.0" }, { "\"string\"", new Utf8("StreamSets"), "StreamSets", "STRING", Types.VARCHAR, "1.0" }, // Complex types are skipped for now // Logical types { DECIMAL.toString(), ByteBuffer.wrap(new byte[] { (byte) 0x0F }), new BigDecimal("2"), "DECIMAL", Types.DECIMAL, "0" }, { DATE.toString(), 17039, new java.sql.Date(116, 7, 26), "DATE", Types.DATE, "1.2" }, }); }