SunQuest
           PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old April 3rd, 2008, 12:19 PM
saikk saikk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 17 saikk Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 59 m 6 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old April 3rd, 2008, 12:53 PM
saikk saikk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 17 saikk Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 h 59 m 6 sec
Reputation Power: 0
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( ) <<<<<<

Reply With Quote
  #3  
Old April 3rd, 2008, 03:09 PM
pgFrank's Avatar
pgFrank pgFrank is offline
So help me Codd
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Location: Brazil
Posts: 129 pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level)pgFrank User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 17 h 35 m 16 sec
Reputation Power: 18
Quote:
expected<2008-04-03 10:12:00.241>but was<2008-04-03 10.01.12.731>

You use . as a separator, your code expects a : Small difference, might be the sollution.

Reply With Quote
  #4  
Old April 4th, 2008, 03:59 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,620 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 4 Days 3 h 39 m 45 sec
Reputation Power: 259
You'd better post this kind of questions in the java forum

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > ResultSet.getTimestamp() - getting errors...pls help...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway