I'm developing a servlet that queries a database of events and returns only events
upcoming. Therefore, I'm trying to filter events already past. Although the query
works fine on my NT development machine using access and sun.jdbc.odbc.JdbcOdbcDriver,
I'm having trouble on sun using mysql and org.gjt.mm.mysql.Driver. The query fails to
filter out old dates using this setup.
I've tried a number of possible methods but none seem to work. I believe that the db
drivers interprets the sql statement differently. Does anyone know how to write the
proper query for finding records after a certain date?
Here's an example of some code that does not eliminate old events.
Calendar calendarToday = Calendar.getInstance();
java.sql.Date searchDate = new java.sql.Date(calendarToday.YEAR,
calendarToday.MONTH, calendarToday.DAY_OF_MONTH);
pstmt = con.prepareStatement(
"SELECT tblEvents.eventName, tblEvents.eventDate, tblEvents.eventCity, "
+ "tblEvents.eventState, tblEvents.eventURL "
+ "FROM tblEvents WHERE tblEvents.eventDate > ? "
+ "ORDER BY tblEvents.eventDate;"
);
synchronized (pstmt) {
pstmt.clearParameters();
pstmt.setDate(1, searchDate);
rs = pstmt.executeQuery();
}
Thanks in advance!
jin
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html