java.sql.Time#setTime ( )源码实例Demo

下面列出了java.sql.Time#setTime ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Flink-CEPplus   文件: SqlTimeSerializer.java
@Override
public Time copy(Time from, Time reuse) {
	if (from == null) {
		return null;
	}
	reuse.setTime(from.getTime());
	return reuse;
}
 
源代码2 项目: Flink-CEPplus   文件: SqlTimeSerializer.java
@Override
public Time deserialize(Time reuse, DataInputView source) throws IOException {
	final long v = source.readLong();
	if (v == Long.MIN_VALUE) {
		return null;
	}
	reuse.setTime(v);
	return reuse;
}
 
源代码3 项目: flink   文件: SqlTimeSerializer.java
@Override
public Time copy(Time from, Time reuse) {
	if (from == null) {
		return null;
	}
	reuse.setTime(from.getTime());
	return reuse;
}
 
源代码4 项目: flink   文件: SqlTimeSerializer.java
@Override
public Time deserialize(Time reuse, DataInputView source) throws IOException {
	final long v = source.readLong();
	if (v == Long.MIN_VALUE) {
		return null;
	}
	reuse.setTime(v);
	return reuse;
}
 
源代码5 项目: phoenix   文件: PhoenixResultSet.java
@Override
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
    checkCursorState();
    Time value = (Time)rowProjector.getColumnProjector(columnIndex-1).getValue(currentRow,
        PTime.INSTANCE, ptr);
    wasNull = (value == null);
    if (value == null) {
        return null;
    }
    cal.setTime(value);
    value.setTime(cal.getTimeInMillis());
    return value;
}
 
源代码6 项目: flink   文件: TimeSerializer.java
@Override
public Time copy(Time from, Time reuse) {
	if (from == null) {
		return null;
	}
	reuse.setTime(from.getTime());
	return reuse;
}
 
源代码7 项目: flink   文件: SqlTimeSerializer.java
@Override
public Time copy(Time from, Time reuse) {
	if (from == null) {
		return null;
	}
	reuse.setTime(from.getTime());
	return reuse;
}
 
源代码8 项目: flink   文件: SqlTimeSerializer.java
@Override
public Time deserialize(Time reuse, DataInputView source) throws IOException {
	final long v = source.readLong();
	if (v == Long.MIN_VALUE) {
		return null;
	}
	reuse.setTime(v);
	return reuse;
}
 
源代码9 项目: phoenix   文件: PhoenixResultSet.java
@Override
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
    checkCursorState();
    Time value = (Time)getRowProjector().getColumnProjector(columnIndex-1).getValue(currentRow,
        PTime.INSTANCE, ptr);
    wasNull = (value == null);
    if (value == null) {
        return null;
    }
    cal.setTime(value);
    value.setTime(cal.getTimeInMillis());
    return value;
}
 
源代码10 项目: phoenix   文件: PhoenixResultSet.java
@Override
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
    checkCursorState();
    Time value = (Time)rowProjector.getColumnProjector(columnIndex-1).getValue(currentRow, PDataType.TIME, ptr);
    wasNull = (value == null);
    if (value == null) {
        return null;
    }
    cal.setTime(value);
    value.setTime(cal.getTimeInMillis());
    return value;
}
 
源代码11 项目: gemfirexd-oss   文件: Datatypes.java
public static synchronized void add_one_row(Connection conn, int thread_id)
throws Exception {
	try {
		//initialize();
		PreparedStatement ps = conn.prepareStatement(
				" insert into Datatypes (id,t_char,t_blob," + "t_clob,"
				+ " t_date, t_decimal, t_decimal_nn, t_double, "
				+ " t_float, t_int, t_longint, t_numeric_large,"
				+ " t_real, t_smallint, t_time, t_timestamp,"
				+ " t_varchar) values ("
				+ " ?,?, ?,?, ?, ?,?, ?, ?, ?,?, ?, ?, ?, ?, ?,?)" 
				/* autoincrement feature added, so we need to specify the
				 * column name for prepared statement, otherwise auto increment
				 * column will think it is trying to update/insert a null value
				 * to the column.
				 */
				, Statement.RETURN_GENERATED_KEYS);
		InputStream streamIn = null;
		Reader streamReader = null;
		int ind = Rn.nextInt();
		double x;
		Date dt = new Date(1);
		Time tt = new Time(1);
		Timestamp ts = new Timestamp(1);
		String cs = "asdf qwerqwer 12341234 ZXCVZXCVZXCV [email protected]#[email protected]#$ asdfasdf 1 q a z asdf ASDF qwerasdfzxcvasdfqwer1234asd#";
		ps.setInt(1, ind);
		// scramble the string
		int i1 = Math.abs(ind % 100);
		String cs2 = cs.substring(i1, 99) + cs.substring(0, i1);
		int i2 = i1 < 89 ? i1 + 10 : i1;
		ps.setString(2, cs2.substring(0, i2));
		//"t_blob"
		int blobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
		streamIn = new LoopingAlphabetStream(blobLength);
		ps.setBinaryStream(3, streamIn, blobLength);
		//"t_clob
		int clobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
		streamReader = new LoopingAlphabetReader(clobLength, CharAlphabet
				.modernLatinLowercase());
		ps.setCharacterStream(4, streamReader, clobLength);
		//"t_ndate"
		dt.setTime(Math.abs(Rn.nextLong() / 150000));
		ps.setDate(5, dt);
		//"t_decimal"
		x = Math.abs(Rn.nextInt() % 18);
		if (x > 5)
			x = 5;
		ps.setDouble(6, Math.abs(Rn.nextDouble() * Math.pow(10, x)));
		//"t_decimal_nn"
		ps.setDouble(7, Rn.nextDouble());
		//"t_double"
		ps.setDouble(8, Rn.nextDouble()
				* Math.pow(10, Math.abs(Rn.nextInt() % 300)));
		//"t_float"
		ps.setFloat(9, Rn.nextFloat()
				* (float) Math.pow(10, Math.abs(Rn.nextInt() % 30)));
		//"t_int"
		ps.setInt(10, Rn.nextInt());
		//"t_longint"
		ps.setLong(11, Rn.nextLong());
		//"t_numeric_large"
		x = Math.abs(Rn.nextInt() % 30);
		if (x > 30)
			x = 31;
		ps.setDouble(12, Math.abs(Rn.nextDouble() * Math.pow(10, x)));
		//"t_real"
		ps.setFloat(13, Rn.nextFloat()
				* (float) Math.pow(10, Math.abs(Rn.nextInt() % 7)));
		//"t_smallint"
		ps.setInt(14, Rn.nextInt() % (256 * 128));
		//"t_time"
		tt.setTime(Math.abs(Rn.nextInt()));
		ps.setTime(15, tt);
		//"t_timestamp"
		ts.setTime(Math.abs(Rn.nextLong() / 50000));
		ps.setTimestamp(16, ts);
		//"t_varchar"
		ps.setString(17, cs.substring(Math.abs(Rn.nextInt() % 100)));
		int rows = ps.executeUpdate();
		if (rows == 1) {

			ResultSet rs = ps.getGeneratedKeys();

			while (rs.next()) {
				ResultSetMetaData rsmd = rs.getMetaData();
				int numCols = rsmd.getColumnCount();
			}
		} else
			System.out.println("t" + thread_id + " insert failed");
		streamReader.close();
		streamIn.close();

	} catch (SQLException se) {
		if (se.getNextException() == null)
			throw se;
		String m = se.getNextException().getSQLState();
		System.out.println(se.getNextException().getMessage()
				+ " SQLSTATE: " + m);
	}
}
 
源代码12 项目: gemfirexd-oss   文件: Datatypes.java
public static synchronized void add_one_row(Connection conn, int thread_id)
throws Exception {
	try {
		//initialize();
		PreparedStatement ps = conn.prepareStatement(
				" insert into Datatypes (id,t_char,t_blob," + "t_clob,"
				+ " t_date, t_decimal, t_decimal_nn, t_double, "
				+ " t_float, t_int, t_longint, t_numeric_large,"
				+ " t_real, t_smallint, t_time, t_timestamp,"
				+ " t_varchar) values ("
				+ " ?,?, ?,?, ?, ?,?, ?, ?, ?,?, ?, ?, ?, ?, ?,?)" 
				/* autoincrement feature added, so we need to specify the
				 * column name for prepared statement, otherwise auto increment
				 * column will think it is trying to update/insert a null value
				 * to the column.
				 */
				, Statement.RETURN_GENERATED_KEYS);
		InputStream streamIn = null;
		Reader streamReader = null;
		int ind = Rn.nextInt();
		double x;
		Date dt = new Date(1);
		Time tt = new Time(1);
		Timestamp ts = new Timestamp(1);
		String cs = "asdf qwerqwer 12341234 ZXCVZXCVZXCV [email protected]#[email protected]#$ asdfasdf 1 q a z asdf ASDF qwerasdfzxcvasdfqwer1234asd#";
		ps.setInt(1, ind);
		// scramble the string
		int i1 = Math.abs(ind % 100);
		String cs2 = cs.substring(i1, 99) + cs.substring(0, i1);
		int i2 = i1 < 89 ? i1 + 10 : i1;
		ps.setString(2, cs2.substring(0, i2));
		//"t_blob"
		int blobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
		streamIn = new LoopingAlphabetStream(blobLength);
		ps.setBinaryStream(3, streamIn, blobLength);
		//"t_clob
		int clobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
		streamReader = new LoopingAlphabetReader(clobLength, CharAlphabet
				.modernLatinLowercase());
		ps.setCharacterStream(4, streamReader, clobLength);
		//"t_ndate"
		dt.setTime(Math.abs(Rn.nextLong() / 150000));
		ps.setDate(5, dt);
		//"t_decimal"
		x = Math.abs(Rn.nextInt() % 18);
		if (x > 5)
			x = 5;
		ps.setDouble(6, Math.abs(Rn.nextDouble() * Math.pow(10, x)));
		//"t_decimal_nn"
		ps.setDouble(7, Rn.nextDouble());
		//"t_double"
		ps.setDouble(8, Rn.nextDouble()
				* Math.pow(10, Math.abs(Rn.nextInt() % 300)));
		//"t_float"
		ps.setFloat(9, Rn.nextFloat()
				* (float) Math.pow(10, Math.abs(Rn.nextInt() % 30)));
		//"t_int"
		ps.setInt(10, Rn.nextInt());
		//"t_longint"
		ps.setLong(11, Rn.nextLong());
		//"t_numeric_large"
		x = Math.abs(Rn.nextInt() % 30);
		if (x > 30)
			x = 31;
		ps.setDouble(12, Math.abs(Rn.nextDouble() * Math.pow(10, x)));
		//"t_real"
		ps.setFloat(13, Rn.nextFloat()
				* (float) Math.pow(10, Math.abs(Rn.nextInt() % 7)));
		//"t_smallint"
		ps.setInt(14, Rn.nextInt() % (256 * 128));
		//"t_time"
		tt.setTime(Math.abs(Rn.nextInt()));
		ps.setTime(15, tt);
		//"t_timestamp"
		ts.setTime(Math.abs(Rn.nextLong() / 50000));
		ps.setTimestamp(16, ts);
		//"t_varchar"
		ps.setString(17, cs.substring(Math.abs(Rn.nextInt() % 100)));
		int rows = ps.executeUpdate();
		if (rows == 1) {

			ResultSet rs = ps.getGeneratedKeys();

			while (rs.next()) {
				ResultSetMetaData rsmd = rs.getMetaData();
				int numCols = rsmd.getColumnCount();
			}
		} else
			System.out.println("t" + thread_id + " insert failed");
		streamReader.close();
		streamIn.close();

	} catch (SQLException se) {
		if (se.getNextException() == null)
			throw se;
		String m = se.getNextException().getSQLState();
		System.out.println(se.getNextException().getMessage()
				+ " SQLSTATE: " + m);
	}
}
 
源代码13 项目: flink   文件: TimeSerializer.java
@Override
public Time deserialize(Time reuse, DataInputView source) throws IOException {
	int time = source.readInt();
	reuse.setTime(time - LOCAL_TZ.getOffset(time));
	return reuse;
}
 
源代码14 项目: spliceengine   文件: Datatypes.java
public static synchronized void add_one_row(Connection conn, int thread_id)
throws Exception {
	try {
		//initialize();
		PreparedStatement ps = conn.prepareStatement(
				" insert into Datatypes (id,t_char,t_blob," + "t_clob,"
				+ " t_date, t_decimal, t_decimal_nn, t_double, "
				+ " t_float, t_int, t_longint, t_numeric_large,"
				+ " t_real, t_smallint, t_time, t_timestamp,"
				+ " t_varchar) values ("
				+ " ?,?, ?,?, ?, ?,?, ?, ?, ?,?, ?, ?, ?, ?, ?,?)" 
				/* autoincrement feature added, so we need to specify the
				 * column name for prepared statement, otherwise auto increment
				 * column will think it is trying to update/insert a null value
				 * to the column.
				 */
				, Statement.RETURN_GENERATED_KEYS);
		InputStream streamIn = null;
		Reader streamReader = null;
		int ind = Rn.nextInt();
		double x;
		Date dt = new Date(1);
		Time tt = new Time(1);
		Timestamp ts = new Timestamp(1);
		String cs = "asdf qwerqwer 12341234 ZXCVZXCVZXCV [email protected]#[email protected]#$ asdfasdf 1 q a z asdf ASDF qwerasdfzxcvasdfqwer1234asd#";
		ps.setInt(1, ind);
		// scramble the string
		int i1 = Math.abs(ind % 100);
		String cs2 = cs.substring(i1, 99) + cs.substring(0, i1);
		int i2 = i1 < 89 ? i1 + 10 : i1;
		ps.setString(2, cs2.substring(0, i2));
		//"t_blob"
		int blobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
		streamIn = new LoopingAlphabetStream(blobLength);
		ps.setBinaryStream(3, streamIn, blobLength);
		//"t_clob
		int clobLength = Rn.nextInt(102400 - 0 + 1) + 0;//to create a stream of random length between 0 and 100K
		streamReader = new LoopingAlphabetReader(clobLength, CharAlphabet
				.modernLatinLowercase());
		ps.setCharacterStream(4, streamReader, clobLength);
		//"t_ndate"
		dt.setTime(Math.abs(Rn.nextLong() / 150000));
		ps.setDate(5, dt);
		//"t_decimal"
		x = Math.abs(Rn.nextInt() % 18);
		if (x > 5)
			x = 5;
		ps.setDouble(6, Math.abs(Rn.nextDouble() * Math.pow(10, x)));
		//"t_decimal_nn"
		ps.setDouble(7, Rn.nextDouble());
		//"t_double"
		ps.setDouble(8, Rn.nextDouble()
				* Math.pow(10, Math.abs(Rn.nextInt() % 300)));
		//"t_float"
		ps.setFloat(9, Rn.nextFloat()
				* (float) Math.pow(10, Math.abs(Rn.nextInt() % 30)));
		//"t_int"
		ps.setInt(10, Rn.nextInt());
		//"t_longint"
		ps.setLong(11, Rn.nextLong());
		//"t_numeric_large"
		x = Math.abs(Rn.nextInt() % 30);
		if (x > 30)
			x = 31;
		ps.setDouble(12, Math.abs(Rn.nextDouble() * Math.pow(10, x)));
		//"t_real"
		ps.setFloat(13, Rn.nextFloat()
				* (float) Math.pow(10, Math.abs(Rn.nextInt() % 7)));
		//"t_smallint"
		ps.setInt(14, Rn.nextInt() % (256 * 128));
		//"t_time"
		tt.setTime(Math.abs(Rn.nextInt()));
		ps.setTime(15, tt);
		//"t_timestamp"
		ts.setTime(Math.abs(Rn.nextLong() / 50000));
		ps.setTimestamp(16, ts);
		//"t_varchar"
		ps.setString(17, cs.substring(Math.abs(Rn.nextInt() % 100)));
		int rows = ps.executeUpdate();
		if (rows == 1) {

			ResultSet rs = ps.getGeneratedKeys();

			while (rs.next()) {
				ResultSetMetaData rsmd = rs.getMetaData();
				int numCols = rsmd.getColumnCount();
			}
		} else
			System.out.println("t" + thread_id + " insert failed");
		streamReader.close();
		streamIn.close();

	} catch (SQLException se) {
		if (se.getNextException() == null)
			throw se;
		String m = se.getNextException().getSQLState();
		System.out.println(se.getNextException().getMessage()
				+ " SQLSTATE: " + m);
	}
}