Knowing I'd be manipulating some dates/times, I thought I'd try the Joda
Time classes form SourceForge in this app. However, it seems to be
complicating, rather than aiding so far. It's a Swing app with SqlServer DB.
BTW: The statement itself works fine if i just pass a literal string for a
date instead of the "?".
private String autoQuery = "select 3, isnull(count(*), 0) " +
"from a_table " +
"where source_type = 4 and fk_status = 3 " +
"and create_date > ?";
PreparedStatement stmt = connection.prepareStatement(autoQuery);
// variable dt is created from org.joda.time.DateTime and passed into this
method
stmt.setDate(1, dt);
the setDate method doesn't like the Joda DateTime type so i tried to
convert:
java.sql.Date jd = new java.sql.Date(dt.toDateTime()); // supposed to
convert to JDK type
but this constructor still doesn't like the type. Plus - I found that
java.sql.Date zeros the time, and i need the seconds
There should be an easier way to do this that I'm missing somehow. Can
anyone be of assistance ?
jim
joeNOSPAM@BEA.com - 14 Feb 2007 16:31 GMT
> Knowing I'd be manipulating some dates/times, I thought I'd try the Joda
> Time classes form SourceForge in this app. However, it seems to be
[quoted text clipped - 25 lines]
>
> jim
You should create and use a java.sql.Timestamp, not a java.sql.Date.
By spec, the java.sql.Date has no time element.
Joe Weinstein at BEA Systems