项目:the-vigilantes
文件:StatementRegressionTest.java
/**
* Tests fix for BUG#54095 - Unnecessary call in newSetTimestampInternal.
*
* This bug was fixed as a consequence of the patch for Bug#71084.
*
* @throws Exception
* if the test fails.
*/
public void testBug54095() throws Exception {
Connection testConn = getConnectionWithProps("useLegacyDatetimeCode=false");
Calendar testCal = Calendar.getInstance();
java.util.Date origDate = testCal.getTime();
PreparedStatement testPstmt = testConn.prepareStatement("SELECT ?");
testPstmt.setTimestamp(1,new Timestamp(0),testCal);
assertEquals("Calendar object shouldn't have changed after PreparedStatement.setTimestamp().",origDate,testCal.getTime());
ResultSet testRs = testPstmt.executeQuery();
testRs.next();
assertEquals("Calendar object shouldn't have changed after PreparedStatement.executeQuery().",testCal.getTime());
testRs.getTimestamp(1,testCal);
assertEquals("Calendar object shouldn't have changed after ResultSet.getTimestamp().",testCal.getTime());
testRs.close();
testPstmt.close();
testConn.close();
}
项目:eXperDB-DB2PG
文件:DataAdapter.java
private void PreparedStmtSetValue(CallableStatement cStmt,int idx,Object obj) throws sqlException{
if (obj instanceof String) {
pStmt.setString(idx,(String) obj);
} else if(obj instanceof Integer){
pStmt.setInt(idx,(Integer) obj);
} else if(obj instanceof BigDecimal){
pStmt.setBigDecimal(idx,(BigDecimal) obj);
} else if(obj instanceof Double){
pStmt.setDouble(idx,(Double) obj);
} else if(obj instanceof Date){
pStmt.setDate(idx,(Date) obj);
} else if(obj instanceof byte[]){
pStmt.setBytes(idx,(byte[]) obj);
} else{
pStmt.setobject(idx,obj);
}
}
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);
}
项目:Homework
文件:DAOEx03.java
@Test
public void testLogin()
{
Pet Pet = new Pet(11,9527,"肥仔",60,40,new Date(2017-1-1),"宝贝");
Scanner sc = new Scanner(system.in);
System.out.println("请输入登陆名:");
String username = sc.next();
System.out.println("请输入密码:");
String password = sc.next();
Master master = new Master(username,password);
Connection conn = DBHelper.getInstance().getConnection();
MasterDao dao = new MasterServiceImpl(conn);
MasterService service = new MasterServiceImpl(dao);
service.login(master);
DBHelper.closeConnection(conn);
}
@Test
public void testGetTaskCountByWorkbasketAndDaysInPastAndState() {
final long daysInPast = 10L;
List<TaskState> taskStates = Arrays.asList(TaskState.CLaimED,TaskState.COMPLETED);
List<DueWorkbasketCounter> expectedResult = new ArrayList<>();
doReturn(expectedResult).when(taskMonitorMapperMock).getTaskCountByWorkbasketIdAndDaysInPastAndState(
any(Date.class),any());
List<DueWorkbasketCounter> actualResult = cut.getTaskCountByWorkbasketAndDaysInPastAndState(daysInPast,taskStates);
verify(taskanaEngineImpl,times(1)).openConnection();
verify(taskMonitorMapperMock,times(1)).getTaskCountByWorkbasketIdAndDaysInPastAndState(any(Date.class),any());
verify(taskanaEngineImpl,times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineConfigurationMock,taskanaEngineMock,taskanaEngineImpl,taskMonitorMapperMock,objectReferenceMapperMock,workbasketServiceMock);
assertthat(actualResult,equalTo(expectedResult));
}
项目:QDrill
文件:HiveTestDataGenerator.java
private String generateTestDataFileForPartitioninput() throws Exception {
final File file = getTempFile();
PrintWriter printWriter = new PrintWriter(file);
String partValues[] = {"1","2","null"};
for(int c = 0; c < partValues.length; c++) {
for(int d = 0; d < partValues.length; d++) {
for(int e = 0; e < partValues.length; e++) {
for (int i = 1; i <= 5; i++) {
Date date = new Date(System.currentTimeMillis());
Timestamp ts = new Timestamp(System.currentTimeMillis());
printWriter.printf("%s,%s,%s",date.toString(),ts.toString(),partValues[c],partValues[d],partValues[e]);
printWriter.println();
}
}
}
}
printWriter.close();
return file.getPath();
}
项目:JAVA-
文件:TypeParseUtil.java
private static Object date2Obj(Object value,String type,String format) {
String fromType = "Date";
java.util.Date dte = (java.util.Date) value;
if ("String".equalsIgnoreCase(type) || DataType.STRING.equalsIgnoreCase(type)) {
if (format == null || format.length() == 0) {
return dte.toString();
} else {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(dte);
}
} else if ("Date".equalsIgnoreCase(type) || DataType.DATE.equalsIgnoreCase(type)) {
return value;
} else if ("java.sql.Date".equalsIgnoreCase(type)) {
return new Date(dte.getTime());
} else if ("Time".equalsIgnoreCase(type) || DataType.TIME.equalsIgnoreCase(type)) {
return new Time(dte.getTime());
} else if ("Timestamp".equalsIgnoreCase(type) || DataType.TIMESTAMP.equalsIgnoreCase(type)) {
return new Timestamp(dte.getTime());
} else {
throw new DataParseException(String.format(support,fromType,type));
}
}
项目:ramus
文件:JDBCTemplate.java
public void setParam(PreparedStatement ps,int parameterIndex,Object object) throws sqlException {
if (object instanceof Timestamp) {
ps.setTimestamp(parameterIndex,(Timestamp) object);
} else if (object instanceof Date) {
ps.setDate(parameterIndex,(Date) object);
} else if (object instanceof String) {
ps.setString(parameterIndex,(String) object);
} else if (object instanceof Integer) {
ps.setInt(parameterIndex,((Integer) object).intValue());
} else if (object instanceof Long) {
ps.setLong(parameterIndex,((Long) object).longValue());
} else if (object instanceof Boolean) {
ps.setBoolean(parameterIndex,((Boolean) object).booleanValue());
} else {
ps.setobject(parameterIndex,object);
}
}
项目:BibliotecaPS
文件:CallableStatementWrapper.java
public void setDate(String parameterName,Date x) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setDate(parameterName,x);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",sqlError.sql_STATE_GENERAL_ERROR,this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
public static Timestamp getnormalisedTimestamp(Date d) {
synchronized (tempCalDefault) {
setTimeInMillis(tempCalDefault,d.getTime());
resetToDate(tempCalDefault);
long value = getTimeInMillis(tempCalDefault);
return new Timestamp(value);
}
}
@Override
public void appendLog(StringBuilder builder,Date parameter,DatabaseDialect dialect) {
// if (DatabaseDialect.MysqL == dialect) {
// builder.append('\'');
// builder.append((null != parameter) ? new SimpleDateFormat("yyyy-MM-dd").format(parameter) : null);
// builder.append('\'');
// }
builder.append('\'');
builder.append((null != parameter) ? new SimpleDateFormat("yyyy-MM-dd").format(parameter) : null);
builder.append('\'');
}
项目:OpenVertretung
文件:CallableStatementWrapper.java
public void setDate(String parameterName,Date x,Calendar cal) throws sqlException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setDate(parameterName,x,cal);
} else {
throw sqlError.createsqlException("No operations allowed after statement closed",this.exceptionInterceptor);
}
} catch (sqlException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
项目:monarch
文件:MPredicateHelperTest.java
/**
* Test for Date values.
*
* @param constant the constant value to be tested
* @param op the operation to be used for testing/condition against constant value
* @param arg1 the value to be compared against the constant value
* @param check boolean indicating the result of predicate test for above
*/
@Test(dataProvider = "getDateData")
public void testGetPredicateForDate(final Object constant,final TypePredicateOp op,final Date arg1,boolean check) {
System.out.printf("PredicateHelperTest.testGetPredicateForDate :: %s -- %s -- %s -- %s\n",constant,op,arg1,check);
assertUsingSerDeForType(BasicTypes.DATE,check);
}
public static Date getnormalisedDate(Date d) {
synchronized (tempCalDefault) {
setTimeInMillis(tempCalDefault,d.getTime());
resetToDate(tempCalDefault);
long value = getTimeInMillis(tempCalDefault);
return new Date(value);
}
}
public static String getDateString(java.util.Date x,Calendar cal) {
synchronized (sdfd) {
sdfd.setCalendar(cal == null ? tempCalDefault
: cal);
return sdfd.format(x);
}
}
项目:JYLAND
文件:JYComment.java
public JYComment(int seq,String id,String content,int boardseq,Date wdate,int likecount,int hatecount,String ip,int seqReply,int ref,int delflag) {
super();
this.seq = seq;
this.id = id;
this.content = content;
this.boardseq = boardseq;
this.wdate = wdate;
this.likecount = likecount;
this.hatecount = hatecount;
this.ip = ip;
this.seqReply = seqReply;
this.ref = ref;
this.delflag = delflag;
}
项目:OpenVertretung
文件:StatementRegressionTest.java
/**
* Tests that binary dates/times are encoded/decoded correctly.
*
* @throws Exception
* if the test fails.
*
* @deprecated because we need to use this particular constructor for the
* date class,as Calendar-constructed dates don't pass the
* .equals() test :(
*/
@Deprecated
public void testServerPrepStmtAndDate() throws Exception {
createTable("testServerPrepStmtAndDate","(`P_ID` int(10) NOT NULL default '0',`R_Date` date default NULL,UNIQUE KEY `P_ID` (`P_ID`),KEY `R_Date` (`R_Date`))");
Date dt = new java.sql.Date(102,2); // Note,this represents the date 2002-02-02
PreparedStatement pStmt2 = this.conn.prepareStatement("INSERT INTO testServerPrepStmtAndDate (P_ID,R_Date) VALUES (171576,?)");
pStmt2.setDate(1,dt);
pStmt2.executeUpdate();
pStmt2.close();
this.rs = this.stmt.executeQuery("SELECT R_Date FROM testServerPrepStmtAndDate");
this.rs.next();
System.out.println("Date that was stored (as String) " + this.rs.getString(1)); // comes back as 2002-02-02
PreparedStatement pStmt = this.conn.prepareStatement("Select P_ID,R_Date from testServerPrepStmtAndDate Where R_Date = ? and P_ID = 171576");
pStmt.setDate(1,dt);
this.rs = pStmt.executeQuery();
assertTrue(this.rs.next());
assertEquals("171576",this.rs.getString(1));
assertEquals(dt,this.rs.getDate(2));
}
项目:dev-courses
文件:JDBCCallableStatement.java
/**
* Internal value converter. Similar to its counterpart in JDBCResultSet <p>
*
* All trivially successful getXXX methods eventually go through this
* method,converting if necessary from the source type to the
* requested type. <p>
*
* Conversion to the JDBC representation,if different,is handled by the
* calling methods.
*
* @param columnIndex of the column value for which to perform the
* conversion
* @param targettype the org.hsqldb.types.Type object for targettype
* @return an Object of the requested targettype,representing the value of the
* specified column
* @throws sqlException when there is no rowData,the column index is
* invalid,or the conversion cannot be performed
*/
private Object getColumnInType(int columnIndex,Type targettype) throws sqlException {
checkGetParameterIndex(columnIndex);
Type sourceType;
Object value;
sourceType = parameterTypes[--columnIndex];
value = parameterValues[columnIndex];
if (trackNull(value)) {
return null;
}
if (sourceType.typeCode != targettype.typeCode) {
try {
value = targettype.convertToTypeJDBC(session,value,sourceType);
} catch (HsqlException e) {
String stringValue =
(value instanceof Number || value instanceof String
|| value instanceof java.util.Date) ? value.toString()
: "instance of " + value.getClass().getName();
String msg = "from sql type " + sourceType.getNameString()
+ " to " + targettype.getJDBcclassName()
+ ",value: " + stringValue;
HsqlException err = Error.error(ErrorCode.X_42561,msg);
throw JDBCUtil.sqlException(err,e);
}
}
return value;
}
项目:atlas
文件:PatchFileBuilder.java
/**
*
* @return
*/
private Manifest createManifest() {
Manifest manifest = new Manifest();
Attributes main = manifest.getMainAttributes();
main.putValue("Manifest-Version","1.0");
main.putValue("Created-By","1.0 (JarPatch)");
main.putValue("Created-Time",new Date(System.currentTimeMillis()).toGMTString());
return manifest;
}
项目:BibliotecaPS
文件:TimeUtil.java
final static Time fastTimeCreate(Calendar cal,int hour,int minute,int second,ExceptionInterceptor exceptionInterceptor) throws sqlException {
if (hour < 0 || hour > 24) {
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,exceptionInterceptor);
}
if (second < 0 || second > 59) {
throw sqlError.createsqlException(
"Illegal minute value '" + second + "' for java.sql.Time type in value '" + timeFormattedString(hour,exceptionInterceptor);
}
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);
}
}
}
/**
*
*/
public void test_requestBugsFromBugzillaCanHandleEmptyProductVersion() throws Exception {
final Date fromDate = stringToDate("2003-02-21 21:03:14");
final Date toDate = stringToDate("2003-05-15 23:07:06");
// empty string as a version
Collection result = bugzillaDatabaseConnector.
requestBugsFromBugzilla(TEST_PRODUCT_NAME,"",fromDate,toDate);
assertEquals(7,result.size());
assertEquals("Number of errors",em.errorCount());
// null string as a version
result = bugzillaDatabaseConnector.
requestBugsFromBugzilla(TEST_PRODUCT_NAME,null,em.errorCount());
}
项目:BibliotecaPS
文件:ResultSetRegressionTest.java
/**
* @deprecated because we use deprecated methods
*/
@Deprecated
public void testBug34913() throws Exception {
Timestamp ts = new Timestamp(new Date(109,5,1).getTime());
this.pstmt = ((com.MysqL.jdbc.Connection) this.conn).serverPrepareStatement("SELECT 'abcdefghij',?");
this.pstmt.setTimestamp(1,ts);
this.rs = this.pstmt.executeQuery();
this.rs.next();
assertTrue(this.rs.getTimestamp(2).getMonth() == 5);
assertTrue(this.rs.getTimestamp(2).getDate() == 1);
}
项目:jooq-flyway-typesafe-migration
文件:v3_AuthorRecord.java
/**
* {@inheritDoc}
*/
@Override
public v3_AuthorRecord values(Integer value1,String value2,String value3,Date value4,Integer value5,String value6,Integer value7) {
value1(value1);
value2(value2);
value3(value3);
value4(value4);
value5(value5);
value6(value6);
value7(value7);
return this;
}
项目:ServiceServer
文件:MovieOnShowController.java
@RequestMapping(path = "/day",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public RestResponse getMovieOnShowByDay(
@RequestParam("movieId") Integer movieId,@RequestParam("cinemaId") Integer cinemaId,@RequestParam("showDate") Date showDate,HttpServletRequest request,HttpServletResponse response) {
LogUtil.logReq(Log,request);
List<Integer> idsList = movieOnShowService.getMovieOnShowByDate(movieId,showDate,cinemaId);
return new CollectionResponse(idsList);
}
项目:tcp
文件:AccionHasProducto.java
public Date getFechaInsercion() {
return fechaInsercion;
}
项目:spr
文件:Version.java
public Date getFechaActualizacion() {
return fechaActualizacion;
}
项目:tcp
文件:Evidencia.java
public Date getFechaInsercion() {
return fechaInsercion;
}
项目:tcp
文件:Hito.java
public Date getFechaInsercion() {
return fechaInsercion;
}
public Date getFechaInsercion() {
return fechaInsercion;
}
项目:DataM
文件:DataHandle.java
public void resolveTable(Map<String,Object> message) {
if (message == null || message.isEmpty() || message.get(key) == null)
return;
DefaultFormattingConversionService cs = new DefaultFormattingConversionService(true);
message.put(key,cs.convert(message.get(key),Long.class));
logger.info("start to resolve message");
String[] baseTableColumn = tDataBase.split(",");
String[] extraTableColumn = tDataExtra.split(",");
String[] customTableColumn = tDataCustom.split(",");
Map<String,Object> baseTable = new HashMap<>();
Map<String,Object> extraTable = new HashMap<>();
Map<String,Object> customTable = new HashMap<>();
long uuid = CustomUUID.get().nextId();
baseTable.put(index,uuid);
extraTable.put(index,uuid);
baseTable.put(attr,new Date((long) message.get(key)));
extraTable.put(attr,new Date((long) message.get(key)));
Arrays.asList(baseTableColumn).stream().forEach(e -> {
baseTable.put(e,message.get(e));
});
Arrays.asList(extraTableColumn).stream().forEach(e -> {
extraTable.put(e,message.get(e));
});
Arrays.asList(customTableColumn).stream().forEach(e -> {
if (message.get(e) == null || "".equals(((String) message.get(e)).trim())) {
return;
}
customTable.put(e,message.get(e));
});
logger.info("start to insert DB");
baseDataReportMapper.insertReportData(baseTable);
exTradataReportMapper.insertReportData(extraTable);
if (customTable.size() > 0) {
customTable.put(index,uuid);
customTable.put(attr,new Date((long) message.get(key)));
Arrays.asList(customTableColumn).stream().forEach(e -> {
if (customTable.get(e) == null || "".equals(((String) customTable.get(e)).trim()))
customTable.put(e,Constants.TABLE_COLUMN_TYPE.get(e));
});
customDataReportMapper.insertReportData(customTable);
}
logger.info("message insert DB successed");
}
项目:tcp
文件:Cronograma.java
public void setFechaActualizacion(Date fechaActualizacion) {
this.fechaActualizacion = fechaActualizacion;
}
public String formatDate(Date dateObject) {
SimpleDateFormat dateFormat = new SimpleDateFormat("LLL dd,yyyy");
String carl = dateFormat.format(dateObject);
return carl;
}
项目:openjdk-jdk10
文件:DateTests.java
项目:tomcat7
文件:Statement.java
项目:jdk8u-jdk
文件:DateTests.java
@Test(expectedExceptions = NullPointerException.class)
public void test15() throws Exception {
LocalDate ld = null;
Date.valueOf(ld);
}
项目:Homework
文件:JDBCEx05.java
public Date getHiredate()
{
return this.hiredate;
}
项目:blanco-sfdc-jdbc-driver
文件:AbstractBlancoGenericJdbcPreparedStatement.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。