Ok I seriously think I'm about to lose it here. This is driving me
nuts!!!
For some reason, I cannot get the following class to run in Android
without throwing a "Wrong Number of SQL Parameters" Exception. It
throws the error on my G1 (Android 1.1) and on my Cupcake Emulator. It
works without fail on every other platform I've tried it on. Also, it
seems to work find if I just copy/paste the insert user method into
the DatabaseDemo app from the Gears Sample application. Does anyone
have any idea what could be happening here? I'm using GWT 1.5.3 and
Gears 1.2.0. I feel like I've tried every possible permutation of this
code and still have not been successful!
Could someone maybe give this thing an old run and test with the
Android Emulator?
Here is the stand alone class:
public class TestGears implements EntryPoint
{
/*--------------------------------------------
| C O N S T A N T S |
============================================*/
private static final String DB_NAME = "moose_db";
private static final String INSERT_USER = "INSERT INTO userTable
(user_id, sessionId, name, email) values ( ?, ?, ?, ? )";
private static final String CREATE_USER_TABLE = "CREATE TABLE IF NOT
EXISTS userTable ( user_id TEXT NOT NULL, sessionId TEXT, name TEXT,
email TEXT )";
/*--------------------------------------------
| I N S T A N C E V A R I A B L E S |
============================================*/
private Database db;
/*--------------------------------------------
| C O N S T R U C T O R S |
============================================*/
/*--------------------------------------------
| P U B L I C A P I M E T H O D S |
============================================*/
public void onModuleLoad()
{
User testUser = new User();
testUser.id = 100L;
testUser.name = "Forced Manual" ;
testUser.currentSessionId = "FAKESESSION";
this.db = Factory.getInstance().createDatabase();
this.db.open( DB_NAME );
try
{
db.execute( "DROP TABLE IF EXISTS userTable" );
this.db.execute( CREATE_USER_TABLE );
}
catch ( DatabaseException e )
{
Window.alert( e.getMessage() );
}
insertUser( testUser );
}
/*--------------------------------------------
| N O N - P U B L I C M E T H O D S |
============================================*/
public void insertUser( User theUser )
{
final String[] params = new String[] { Long.toString(
theUser.id ) ,
theUser.currentSessionId , theUser.name , "" };
try
{
db.execute( INSERT_USER, params );
}
catch ( DatabaseException e )
{
String parameterString = new String();
parameterString += "[ ";
for ( String param : params )
{
parameterString += param + ", ";
}
parameterString = parameterString.substring( 0,
parameterString.length() - 2 );
parameterString += " ]";
Window.alert( "insertUser: " + e.getMessage() + " - " +
parameterString );
}
}
/*--------------------------------------------
| I N L I N E C L A S S E S |
============================================*/
public class User
{
public Long id;
public String name = new String();
public String currentSessionId = new String();
}
}
On May 5, 2:24 pm, Evan Ruff <[email protected]> wrote:
> Oh also, I should add, that I checked out the DB structure using the
> little DB explorer guy that is available in the vanilla gears distro.
>
> The SQLite DB looks identical as the one on the other platforms, just
> without data ('cause of all the SQL errors, I assume)
>
> Thanks!
>
> E
>
> On May 5, 2:22 pm,EvanRuff<[email protected]> wrote:
>
> > Hey guys,
>
> > I've got a pretty heavy gears app the works great in IE, Firefox and
> > Chrome; however, I'm getting some inconsistencies when running it on
> > Android using Gears GWT API 1.2.0. Whenever I seem to run ANY query, I
> > get a "Wrong number of SQL parameters" DatabaseException. Everything
> > works perfectly in the other browsers.
>
> > I'm debugging back to the client and my info is:
> > Exception Message: Wrong number of SQL parameters.
> > Method: selectUserByUserId
> > Parameters: [ 1 ]
>
> > Here is the method:
>
> > private static final String SELECT_USER = "SELECT user_id, sessionId,
> > name, email FROM user WHERE user_id = ?";
>
> > public User selectUserByUserId( long userId )
> > {
> > final String[] params = new String[] { Long.toString( userId ) };
> > try
> > {
> > ResultSet rs = db.execute( SELECT_USER, params );
> > for ( int i = 0; rs.isValidRow(); ++i, rs.next() )
> > {
> > User user = new User();
> > user.setId( rs.getFieldAsLong( 0 ) );
> > user.setCurrentSessionId( rs.getFieldAsString( 1 )
> > );
> > user.setName( rs.getFieldAsString( 2 ) );
> > return user;
> > }
> > rs.close();
> > }
> > catch ( DatabaseException e )
> > {
> > debugDBException( "selectUserByUserId", params, e );
> > }
> > return null;
>
> > }
>
> > The debugDBException method just rolls everything up an submits it to
> > the server.
>
> > Has anone else had this sort of issue working with Gears on Android?
> > I've tried the test 1.2 Gears LocalDB Test and it seems to fine. It
> > looks like I'm trying to do a VERY similar thing and I'm really
> > perplexed as to why it won't work.
>
> > Thanks!
>
> >Evan
>
> > PS. Should I cross post this to the gears group?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---