Hey Eric,
I'm pretty much terrified of Javascript.
I'm a little hesitant to make any determination whatsoever as to the
cause of the problem. When I run the GWT Gears Sample DatabaseDemo
project, it works as expected. I can even replace all of the DB
specifics with the internals of my tables/queries and it seems to
work! It's just so freakin' frustrating.
RememberTheMilk and the mobile GMail seem to make use of Gears on
Android without issue, so I really don't know where to go from here.
Any other suggestions?
Here's the replaced DatabaseDemo code, fwiw:
public class Gears implements EntryPoint
{
private static final int NUM_SAVED_ROWS = 3;
private static final int NUM_DATA_TABLE_COLUMNS = 3;
private final Button addButton = new Button( "Add" );
private final Button clearButton = new Button( "Clear Database" );
private Database db;
private final TextBox input = new TextBox();
private final FlexTable dataTable = new FlexTable();
public void onModuleLoad()
{
VerticalPanel outerPanel = new VerticalPanel();
outerPanel.setSpacing( 10 );
outerPanel.getElement().getStyle().setPropertyPx( "margin", 15 );
HorizontalPanel textAndButtonsPanel = new HorizontalPanel();
textAndButtonsPanel.add( new Label( "Enter a Phrase: " ) );
textAndButtonsPanel.add( input );
textAndButtonsPanel.add( addButton );
textAndButtonsPanel.add( clearButton );
outerPanel.add( textAndButtonsPanel );
outerPanel.add( new Label( "Last 3 Entries:" ) );
outerPanel.add( dataTable );
for ( int i = 0; i <= NUM_SAVED_ROWS; ++i )
{
dataTable.insertRow( i );
for ( int j = 0; j < NUM_DATA_TABLE_COLUMNS; j++ )
{
dataTable.addCell( i );
}
}
dataTable.setWidget( 0, 0, new HTML( "<b>Id</b>" ) );
dataTable.setWidget( 0, 1, new HTML( "<b>Phrase</b>" ) );
dataTable.setWidget( 0, 2, new HTML( "<b>Timestamp</b>" ) );
// Create the database if it doesn't exist.
try
{
db = Factory.getInstance().createDatabase();
db.open( "database-demo" );
db.execute( "DROP TABLE IF EXISTS user" );
db.execute( "CREATE TABLE IF NOT EXISTS user ( user_id TEXT NOT
NULL, sessionId TEXT, name TEXT, email TEXT )" );
}
catch ( DatabaseException e )
{
RootPanel.get( "demo" ).add( new HTML( "Error opening or creating
database: <font color=\"red\">" + e.toString() + "</font>" ) );
// Fatal error. Do not build the interface.
return;
}
input.addKeyboardListener( new KeyboardListenerAdapter()
{
@Override
public void onKeyDown( Widget sender, char keyCode, int modifiers )
{
if (keyCode == KeyboardListener.KEY_ENTER)
{
insertPhrase();
}
}
} );
addButton.addClickListener( new ClickListener()
{
public void onClick( Widget sender )
{
insertPhrase();
}
} );
clearButton.addClickListener( new ClickListener()
{
public void onClick( Widget sender )
{
clearPhrases();
displayRecentPhrases();
}
} );
RootPanel.get( "demo" ).add( outerPanel );
displayRecentPhrases();
}
/**
* Remove all phrases from the database.
*/
private void clearPhrases()
{
try
{
db.execute( "DELETE FROM Phrases" );
}
catch ( DatabaseException e )
{
Window.alert( e.toString() );
}
}
/**
* Fill the labels with the phrases from the database.
*/
private void displayRecentPhrases()
{
try
{
ResultSet rs = db.execute( "SELECT name, email FROM user" );
int i;
for ( i = 1; rs.isValidRow(); ++i, rs.next() )
{
if (i <= NUM_SAVED_ROWS)
{
dataTable.setText( i, 0, i+"" );
dataTable.setText( i, 1, rs.getFieldAsString( 0 ) );
dataTable.setText( i, 2, new Date( rs.getFieldAsLong
( 1 ) ).toString() );
}
else
{
db.execute( "DELETE FROM user" );
}
}
// If a phrase has been removed, clear the label.
for ( ; i <= NUM_SAVED_ROWS; i++ )
{
for ( int j = 0; j < NUM_DATA_TABLE_COLUMNS; j++ )
{
dataTable.clearCell( i, j );
}
}
rs.close();
}
catch ( DatabaseException e )
{
Window.alert( e.toString() );
}
}
/**
* Add a new phrase to the database.
*/
private void insertPhrase()
{
try
{
this.db.execute( "INSERT INTO user (user_id, sessionId, name,
email) values ( ?, ?, ?, ? )" , new String[] { "stupid", "fake",
"shit", "balls" } );
displayRecentPhrases();
input.setText( "" );
}
catch ( DatabaseException e )
{
Window.alert( e.toString() );
}
}
On May 6, 1:47 pm, Eric Ayers <
zun...@google.com> wrote:
> If it turns out to be reproducible outside of GWT, I was going to point you
> at the android-developers google group.
http://groups.google.com/group/android-developers