项目:jetfuel
文件:FloatAdapter.java
/**
* Changes the type of the source to a Float object;
*/
@Override
protected Float changeType(Class<?> sourceClass,Object source) {
if (Number.class.isAssignableFrom(sourceClass))
return ((Number) source).floatValue();
else if (Date.class.isAssignableFrom(sourceClass))
return (float) ((Date) source).getTime();
else if (java.sql.Date.class.isAssignableFrom(sourceClass))
return (float) ((java.sql.Date) source).getTime();
else if (Time.class.isAssignableFrom(sourceClass))
return (float) ((Time) source).getTime();
else if (Timestamp.class.isAssignableFrom(sourceClass))
return (float) ((Timestamp) source).getTime();
else
return super.changeType(sourceClass,source);
}
项目:the-vigilantes
文件:StatementRegressionTest.java
private void checkPreparedStatementForTestBug50348(Connection testConn,Timestamp timestamp,Time time,String expectedTimestamp,String expectedTime)
throws sqlException {
PreparedStatement testPstmt = testConn.prepareStatement("SELECT ?,?");
testPstmt.setTimestamp(1,timestamp);
testPstmt.setTime(2,time);
this.rs = testPstmt.executeQuery();
this.rs.next();
String timestampAsstring = new String(this.rs.getBytes(1));
String timeAsstring = new String(this.rs.getBytes(2));
String alert = expectedTimestamp.equals(timestampAsstring) && expectedTime.equals(timeAsstring) ? "" : " <-- (!)";
System.out.printf("[PS] expected: '%s' | '%s'%n",expectedTimestamp,expectedTime);
System.out.printf(" actual: '%s' | '%s' %s%n",timestampAsstring,timeAsstring,alert);
assertEquals(expectedTimestamp,timestampAsstring);
assertEquals(expectedTime,timeAsstring);
}
项目:morpheus-core
文件:DbSink.java
@Override
void apply(PreparedStatement stmt,int stmtIndex,DataFrameRow<R,C> row) {
final R rowKey = row.key();
try {
switch (rowKeyType) {
case BIT: stmt.setBoolean(stmtIndex,rowKeyMapper.applyAsBoolean(rowKey)); break;
case BOOLEAN: stmt.setBoolean(stmtIndex,rowKeyMapper.applyAsBoolean(rowKey)); break;
case tinyint: stmt.setInt(stmtIndex,rowKeyMapper.applyAsInt(rowKey)); break;
case SMALLINT: stmt.setInt(stmtIndex,rowKeyMapper.applyAsInt(rowKey)); break;
case FLOAT: stmt.setDouble(stmtIndex,rowKeyMapper.applyAsDouble(rowKey)); break;
case INTEGER: stmt.setInt(stmtIndex,rowKeyMapper.applyAsInt(rowKey)); break;
case BIGINT: stmt.setLong(stmtIndex,rowKeyMapper.applyAsLong(rowKey)); break;
case DOUBLE: stmt.setDouble(stmtIndex,rowKeyMapper.applyAsDouble(rowKey)); break;
case DECIMAL: stmt.setDouble(stmtIndex,rowKeyMapper.applyAsDouble(rowKey)); break;
case VARCHAR: stmt.setString(stmtIndex,(String)rowKeyMapper.apply(rowKey)); break;
case DATE: stmt.setDate(stmtIndex,(Date)rowKeyMapper.apply(rowKey)); break;
case TIME: stmt.setTime(stmtIndex,(Time)rowKeyMapper.apply(rowKey)); break;
case DATETIME: stmt.setTimestamp(stmtIndex,(Timestamp)rowKeyMapper.apply(rowKey)); break;
default: throw new IllegalStateException("Unsupported column type:" + rowKeyType);
}
} catch (Exception ex) {
throw new DataFrameException("Failed to apply row key to sql statement at " + rowKey,ex);
}
}
项目:ProyectoPacientes
文件:StatementRegressionTest.java
private void checkPreparedStatementForTestBug50348(Connection testConn,timeAsstring);
}
public void testDateTypestoBigInt() throws Exception {
final int TOTAL_RECORDS = 1 * 10;
long offset = TimeZone.getDefault().getRawOffset();
String table = getTableName().toupperCase();
ColumnGenerator[] cols = new ColumnGenerator[] {
HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),"date",Types.DATE,HCatFieldSchema.Type.BIGINT,0 - offset,new Date(70,1),KeyType.NOT_A_KEY),HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),"time",Types.TIME,36672000L - offset,new Time(10,11,12),HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(2),"timestamp",Types.TIMESTAMP,new Timestamp(70,1,10,12,0),};
List<String> addlArgsArray = new ArrayList<String>();
addlArgsArray.add("--map-column-hive");
addlArgsArray.add("COL0=bigint,COL1=bigint,COL2=bigint");
runHCatExport(addlArgsArray,TOTAL_RECORDS,table,cols);
}
项目:OpenVertretung
文件:PreparedStatement.java
/**
* Set a parameter to a java.sql.Time value. The driver converts this to a
* sql TIME value when it sends it to the database,using the given
* timezone.
*
* @param parameterIndex
* the first parameter is 1...));
* @param x
* the parameter value
* @param tz
* the timezone to use
*
* @throws java.sql.sqlException
* if a database access error occurs
*/
private void setTimeInternal(int parameterIndex,Time x,Calendar targetCalendar,TimeZone tz,boolean rollForward) throws java.sql.sqlException {
if (x == null) {
setNull(parameterIndex,java.sql.Types.TIME);
} else {
checkClosed();
if (!this.useLegacyDatetimeCode) {
newSetTimeInternal(parameterIndex,x,targetCalendar);
} else {
Calendar sessionCalendar = getCalendarInstanceForSessionorNew();
x = TimeUtil.changeTimezone(this.connection,sessionCalendar,targetCalendar,tz,this.connection.getServerTimezoneTZ(),rollForward);
setInternal(parameterIndex,"'" + x.toString() + "'");
}
this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.TIME;
}
}
项目:jetfuel
文件:DatabaseCommand.java
/**
* Appends a time to the underlying command;
*
* @param time
* @return
*/
public DatabaseCommand appendTime(Time time) {
this.text.append('\'');
this.text.append(time);
this.text.append('\'');
return this;
}
void createFactHeader(int nFactId,int nClientId)
{
Date date = new Date();
Time time = new Time(date.getTime());
String csDate = String.valueOf(time);
sql("insert into VIT102 (ID,CLIENTID,FACTDATE) VALUES (#1,#2,#3)")
.value(1,nFactId)
.value(2,nClientId)
.value(3,csDate);
}
项目:jetfuel
文件:TimeAdapter.java
/**
* Changes the type of the source object to this adapter's data type;
*/
@Override
protected Time changeType(Class<?> sourceClass,Object source) {
if (Date.class.isAssignableFrom(sourceClass))
return new Time(((Date) source).getTime());
else if (Number.class.isAssignableFrom(sourceClass))
return new Time(((Number) source).longValue());
else
return super.changeType(sourceClass,source);
}
项目:openjdk-jdk10
文件:BaseRowSetTests.java
项目:ProyectoPacientes
文件:CallableStatementWrapper.java
public Time getTime(String parameterName,Calendar cal) throws sqlException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getTime(parameterName,cal);
}
throw sqlError.createsqlException("No operations allowed after statement closed",sqlError.sql_STATE_GENERAL_ERROR,this.exceptionInterceptor);
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
项目:ProyectoPacientes
文件:BufferRow.java
@Override
public Time getTimeFast(int columnIndex,boolean rollForward,MysqLConnection conn,ResultSetImpl rs)
throws sqlException {
if (isNull(columnIndex)) {
return null;
}
findAndSeekToOffset(columnIndex);
long length = this.rowFromServer.readFieldLength();
int offset = this.rowFromServer.getPosition();
return getTimeFast(columnIndex,this.rowFromServer.getByteBuffer(),offset,(int) length,rollForward,conn,rs);
}
项目:ProyectoPacientes
文件:ByteArrayRow.java
@Override
public Time getTimeFast(int columnIndex,ResultSetImpl rs)
throws sqlException {
byte[] columnValue = this.internalRowData[columnIndex];
if (columnValue == null) {
return null;
}
return getTimeFast(columnIndex,this.internalRowData[columnIndex],columnValue.length,rs);
}
项目:spanner-jdbc
文件:CloudSpannerResultSetTest.java
@Test
public void testGetTimeLabel() throws sqlException
{
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.clear();
cal.set(1970,14,6,15);
assertNotNull(subject.getTime(TIME_COL_NOT_NULL));
assertEquals(new Time(cal.getTimeInMillis()),subject.getTime(TIME_COL_NOT_NULL));
assertEquals(false,subject.wasNull());
assertNull(subject.getTime(TIME_COL_NULL));
assertTrue(subject.wasNull());
}
项目:jdk8u-jdk
文件:TimeTests.java
@Test
public void test19() {
Time t = Time.valueOf("08:30:59");
Time t2 = new Time(t.getTime());
assertFalse(t.after(t2),"Error t.after(t2) = true");
assertFalse(t2.after(t),"Error t2.after(t) = true");
}
项目:lams
文件:TimeUtil.java
final static Time fastTimeCreate(int hour,int minute,int second,ExceptionInterceptor exceptionInterceptor) throws sqlException {
if (hour < 0 || hour > 23) {
throw sqlError.createsqlException("Illegal hour value '" + hour + "' for java.sql.Time type in value '" + timeFormattedString(hour,minute,second)
+ ".",sqlError.sql_STATE_ILLEgal_ARGUMENT,exceptionInterceptor);
}
if (minute < 0 || minute > 59) {
throw sqlError.createsqlException(
"Illegal minute value '" + minute + "' for java.sql.Time type in value '" + timeFormattedString(hour,second) + ".",exceptionInterceptor);
}
if (second < 0 || second > 59) {
throw sqlError.createsqlException(
"Illegal minute value '" + second + "' for java.sql.Time type in value '" + timeFormattedString(hour,exceptionInterceptor);
}
Calendar cal = (targetCalendar == null) ? new GregorianCalendar() : targetCalendar;
synchronized (cal) {
java.util.Date origCalDate = cal.getTime();
try {
cal.clear();
// Set 'date' to epoch of Jan 1,1970
cal.set(1970,hour,second);
long timeAsMillis = cal.getTimeInMillis();
return new Time(timeAsMillis);
} finally {
cal.setTime(origCalDate);
}
}
}
项目:BibliotecaPS
文件:ByteArrayRow.java
@Override
public Time getTimeFast(int columnIndex,rs);
}
项目:ProyectoPacientes
文件:ResultSetImpl.java
protected Time fastTimeCreate(Calendar cal,int hour,int second) throws sqlException {
synchronized (checkClosed().getConnectionMutex()) {
if (!this.useLegacyDatetimeCode) {
return TimeUtil.fastTimeCreate(hour,second,cal,getExceptionInterceptor());
}
if (cal == null) {
cal = getFastDefaultCalendar();
}
return TimeUtil.fastTimeCreate(cal,getExceptionInterceptor());
}
}
项目:iBase4J-Common
文件:TypeParseUtil.java
private static Object long2Obj(Object value,String type,Locale locale) {
String fromType = "Long";
Long lng = (Long) value;
if ("String".equalsIgnoreCase(type) || DataType.STRING.equalsIgnoreCase(type)) {
return getNf(locale).format(lng.toString());
} else if ("Double".equalsIgnoreCase(type) || DataType.DOUBLE.equalsIgnoreCase(type)) {
return new Double(lng.toString());
} else if ("Float".equalsIgnoreCase(type) || DataType.FLOAT.equalsIgnoreCase(type)) {
return new Float(lng.toString());
} else if ("BigDecimal".equalsIgnoreCase(type) || DataType.BIGDECIMAL.equalsIgnoreCase(type)) {
return new BigDecimal(lng.toString());
} else if ("Long".equalsIgnoreCase(type) || DataType.LONG.equalsIgnoreCase(type)) {
return value;
} else if ("Integer".equalsIgnoreCase(type) || DataType.INTEGER.equalsIgnoreCase(type)) {
return new Integer(lng.toString());
} else if ("Date".equalsIgnoreCase(type) || DataType.DATE.equalsIgnoreCase(type)) {
return new java.util.Date(lng);
} else if ("java.sql.Date".equalsIgnoreCase(type)) {
return new Date(lng);
} else if ("Time".equalsIgnoreCase(type) || DataType.TIME.equalsIgnoreCase(type)) {
return new Time(lng);
} else if ("Timestamp".equalsIgnoreCase(type) || DataType.TIMESTAMP.equalsIgnoreCase(type)) {
return new Timestamp(lng);
} else {
throw new DataParseException(String.format(support,fromType,type));
}
}
项目:jdk8u-jdk
文件:BaseRowSetTests.java
@test()
public void baseRowSetTest0014() throws Exception {
Calendar cal = Calendar.getInstance();
brs = new StubBaseRowSet();
brs.setTime(1,cal));
}
项目:BibliotecaPS
文件:CallableStatement.java
/**
* @see java.sql.CallableStatement#getTime(int)
*/
public Time getTime(int parameterIndex) throws sqlException {
synchronized (checkClosed().getConnectionMutex()) {
ResultSetInternalMethods rs = getoutputParameters(parameterIndex);
Time retValue = rs.getTime(mapOutputParameterIndexToRsIndex(parameterIndex));
this.outputParamWasNull = rs.wasNull();
return retValue;
}
}
项目:BibliotecaPS
文件:CallableStatement.java
/**
* @see java.sql.CallableStatement#getTime(java.lang.String,java.util.Calendar)
*/
public Time getTime(String parameterName,Calendar cal) throws sqlException {
synchronized (checkClosed().getConnectionMutex()) {
ResultSetInternalMethods rs = getoutputParameters(0); // definitely not going to be from ?=
Time retValue = rs.getTime(fixParameterName(parameterName),cal);
this.outputParamWasNull = rs.wasNull();
return retValue;
}
}
项目:BibliotecaPS
文件:TimeUtil.java
/**
* Change the given times from one timezone to another
*
* @param conn
* the current connection to the MysqL server
* @param t
* the times to change
* @param fromTz
* the timezone to change from
* @param toTz
* the timezone to change to
*
* @return the times changed to the timezone 'toTz'
*/
public static Time changeTimezone(MysqLConnection conn,Calendar sessionCalendar,Time t,TimeZone fromTz,TimeZone toTz,boolean rollForward) {
if ((conn != null)) {
if (conn.getUseTimezone() && !conn.getNoTimezoneConversionForTimeType()) {
// Convert the timestamp from GMT to the server's timezone
Calendar fromCal = Calendar.getInstance(fromTz);
fromCal.setTime(t);
int fromOffset = fromCal.get(Calendar.ZONE_OFFSET) + fromCal.get(Calendar.DST_OFFSET);
Calendar toCal = Calendar.getInstance(toTz);
toCal.setTime(t);
int toOffset = toCal.get(Calendar.ZONE_OFFSET) + toCal.get(Calendar.DST_OFFSET);
int offsetDiff = fromOffset - toOffset;
long toTime = toCal.getTime().getTime();
if (rollForward) {
toTime += offsetDiff;
} else {
toTime -= offsetDiff;
}
Time changedTime = new Time(toTime);
return changedTime;
} else if (conn.getUseJDBCCompliantTimezoneshift()) {
if (targetCalendar != null) {
Time adjustedTime = new Time(jdbcCompliantZoneshift(sessionCalendar,t));
return adjustedTime;
}
}
}
return t;
}
项目:BibliotecaPS
文件:ResultSetImpl.java
Time getNativeTimeViaParseConversion(int columnIndex,boolean rollForward) throws sqlException {
if (this.useUsageAdvisor) {
issueConversionViaParsingWarning("getTime()",columnIndex,this.thisRow.getColumnValue(columnIndex - 1),this.fields[columnIndex - 1],new int[] { MysqLDefs.FIELD_TYPE_TIME });
}
String strTime = getNativeString(columnIndex);
return getTimeFromString(strTime,rollForward);
}
/**
* Converts a string in JDBC date escape format to a
* <code>Time</code> value.
*
* @param s date in format <code>hh:mm:ss</code>
* @return corresponding <code>Time</code> value
* @exception java.lang.IllegalArgumentException if the given argument
* does not have the format <code>hh:mm:ss</code>
*/
public static Time timeValue(String s) {
if (s == null) {
throw new java.lang.IllegalArgumentException(
Trace.getMessage(Trace.HsqlDateTime_null_string));
}
return Time.valueOf(s);
}
项目:lams
文件:ResultSetRow.java
public abstract Time getTimeFast(int columnIndex,ResultSetImpl rs)
throws sqlException;
项目:ProyectoPacientes
文件:ResultSetRow.java
public abstract Time getNativeTime(int columnIndex,ResultSetImpl rs)
throws sqlException;
项目:HTAPBench
文件:AutoIncrementPreparedStatement.java
项目:openjdk-jdk10
文件:StubSyncResolver.java
@Override
public void updateTime(int columnIndex,Time x) throws sqlException {
throw new UnsupportedOperationException("Not supported yet.");
}
项目:apache-tomcat-7.0.73-with-comment
文件:ResultSet.java
项目:Agent-Benchmarks
文件:SimulateResultSet.java
@Override public Time getTime(String columnLabel,Calendar cal) throws sqlException {
return null;
}
项目:blanco-sfdc-jdbc-driver
文件:BlancoGenericJdbcResultSet.java
项目:openjdk-jdk10
文件:StubJdbcRowSetImpl.java
@Override
public Time getTime(String columnLabel,Calendar cal) throws sqlException {
throw new UnsupportedOperationException("Not supported yet.");
}
项目:picocli
文件:CommandLineTypeConversionTest.java
@Test
public void testTimeFormatHHmmssSupported() throws ParseException {
SupportedTypes bean = CommandLine.populateCommand(new SupportedTypes(),"-Time","23:59:58");
assertEquals("Time",new Time(new SimpleDateFormat("HH:mm:ss").parse("23:59:58").getTime()),bean.aTimeField);
}
@Test
public void test_Time_withType() throws Exception {
assertObjectWithType(new Time(System.currentTimeMillis()),Time.class);
}
项目:jdk8u-jdk
文件:StubJoinRowSetImpl.java
@Override
public void updateTime(int columnIndex,Time x) throws sqlException {
throw new UnsupportedOperationException("Not supported yet.");
}
项目:jdk8u-jdk
文件:StubJdbcRowSetImpl.java
@Override
public Time getTime(String columnLabel) throws sqlException {
throw new UnsupportedOperationException("Not supported yet.");
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。