views:

176

answers:

2

I have a Users table that has an element called "date". I would like to make these pseudocode queries work in Java:

select * from Users WHERE date=today

and also

select * from Users WHERE date "in this hour"

How can I write the queries?

I am using Google App Engine, and the date was initially created using java.util.Date.

Please help. Thanks

A: 
PreparedStatement st = conn.prepareStatement("select * from Users where date = ?");
st.setDate(1, new java.sql.Date(System.currentMillis());
ResultSet rs = st.executeQuery();

jiql is a Java JDBC wrapper for Cloud computing databases. The database is accessed via the jiql jdbc client. The data is actually stored in a cloud-based data store, such as Google's BigTable.

http://www.jiql.org/xwiki/bin/view/Main/

jspcal
You cannot use JDBC on App Engine.
Thilo
@Thilo, those classes are whitelisted: http://code.google.com/appengine/docs/java/jrewhitelist.html
jspcal
@jspcal: That does not mean that they do anything useful ...
Thilo
@Thilo, its pretty nice they actually work. it's useful so you can re-use existing code (check out jiql)
jspcal
Okay, with the interesting link to jiql, this answer makes sense. Not sure how valid this approach is though...
Thilo
+1  A: 

Since a date in GoogleAppEngine specifies time down to the millisecond using "=" will not likely work.

It appears you could do something like the following:

select from Users where date >= midnightWesnesday
                      && date < midnightThusday;

You should also be able to specify the correct range for the hour accordingly.

Jay Askren