Thursday, May 31, 2012

sql statement works in local mysql dev instance, but not with google cloud sql

When using the latest Appengine/Google plugin for Eclipse, I'm seeing a difference in how my local MySQL dev database and Google Cloud SQL behave.

I'm doing:
 
String stmt = "SELECT somefield FROM sometable WHERE somekey=?";
PreparedStatement pstmt = (PreparedStatement)conn.prepareStatement(stmt);
pstmt.setString(1, someid);
ResultSet rs = pstmt.executeQuery();
 
It runs locally, but the query returns no results when run from the cloud.  The databases are exactly the same and the query works when I use a static SQL statement in the code, instead of one that uses the setString() symbol replacement as above.  Has anyone seen this before, and if so, how should I change my code, so that it works on Google Cloud SQL as well as MySQL?  Thanks in advance!

No comments:

Post a Comment