|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
ResultSet.getTimestamp() - getting errors...pls help...
Here is my code :
--------------------------- try { PreparedStatement statement; String category = "chud"; // dumpCounters (connection.getConnection(), category); statement = connection.getPreparedStatement ("SELECT eventID, eventStart, eventEnd FROM Counter WHERE categoryID = (SELECT categoryID FROM Category WHERE CategoryName = ?)"); try { java.sql.Timestamp stamp = null; ResultSet rs; statement.setString (1, category); rs = statement.executeQuery (); while (rs.next ()) { int eventid; java.sql.Timestamp start; java.sql.Timestamp end; eventid = rs.getInt(1); start = rs.getTimestamp(2); log.debug("rs.getTimestamp(2): " + rs.getTimestamp(2)); end = rs.getTimestamp(3); log.debug("rs.getTimestamp(3) : " + rs.getTimestamp(3)); if (stamp == null) { stamp = start; log.debug("stamp : " + stamp); } log.debug("start : " + start); assertEquals (stamp, start); assertEquals (stamp, end); log.debug (rs.getLong (1) + " '" + rs.getTimestamp (2) + "' '" + rs.getTimestamp (3) + "'"); } } finally { statement.close (); } } finally { component.returnConnection (connection); } ---------------------------------------------------------------------------------------- When I run this, i get the following error : junit.AssertionFailedError : expected<2008-04-03 10:12:00.241>but was<2008-04-03 10.01.12.731> Please respond soon.. Thanks. |
|
#2
|
|||
|
|||
|
ResultSet.getTimestamp()-getting errors..pls help
Here is the stack trace :
6423 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:46:09.295 6423 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6423 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:46:09.295 6423 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6424 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:46:09.295 6424 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:46:09.295 6425 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - 384 '2008-04-03 10:46:09.295' '2008-04-03 10:46:09.295' 6425 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:46:09.295 6426 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6426 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:46:09.295 6426 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6426 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:46:09.295 6427 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:46:09.295 6428 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - 382 '2008-04-03 10:46:09.295' '2008-04-03 10:46:09.295' 6428 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:46:09.295 6429 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6429 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:46:09.295 6429 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6431 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:46:09.295 6431 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:46:09.295 6432 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - 380 '2008-04-03 10:46:09.295' '2008-04-03 10:46:09.295' 6433 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:46:09.295 6433 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6434 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:46:09.295 6434 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6434 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:46:09.295 6434 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:46:09.295 6434 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - 378 '2008-04-03 10:46:09.295' '2008-04-03 10:46:09.295' 6436 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:46:09.295 6436 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6438 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:46:09.295 6438 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6438 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:46:09.295 6438 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:46:09.295 6438 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - 376 '2008-04-03 10:46:09.295' '2008-04-03 10:46:09.295' 6439 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:46:09.295 6440 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6440 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:46:09.295 6440 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6441 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:46:09.295 6441 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:46:09.295 6441 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - 374 '2008-04-03 10:46:09.295' '2008-04-03 10:46:09.295' 6442 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:46:09.295 6442 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6442 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:46:09.295 6443 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6443 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:46:09.295 6444 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:46:09.295 6444 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - 372 '2008-04-03 10:46:09.295' '2008-04-03 10:46:09.295' 6445 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:46:09.295 6445 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6446 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:46:09.295 6446 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6446 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:46:09.295 6446 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:46:09.295 6446 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - 370 '2008-04-03 10:46:09.295' '2008-04-03 10:46:09.295' 6447 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(2): 2008-04-03 10:44:31.716 6448 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.next() : true 6450 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - rs.getTimestamp(3) : 2008-04-03 10:44:31.716 6451 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - stamp : 2008-04-03 10:46:09.295 6451 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - start : 2008-04-03 10:44:31.716 6451 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - end : 2008-04-03 10:44:31.716 6457 [main] DEBUG com.sendmail.iocaine.xxl.counter.test.TestCounterExpressions - >>>>>> Ending Test: testAppendExpressionDeferredTimestamps( ) <<<<<< |
|
#3
|
||||
|
||||
|
Quote:
You use . as a separator, your code expects a : Small difference, might be the sollution. |
|
#4
|
||||
|
||||
|
You'd better post this kind of questions in the java forum
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
![]() |
| Viewing: Dev Shed Forums > Databases > PostgreSQL Help > ResultSet.getTimestamp() - getting errors...pls help... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|