Zn2O / gwt-google-apis

Automatically exported from code.google.com/p/gwt-google-apis
0 stars 0 forks source link

Database.execute() throws exceptions that are not DatabaseExceptions #120

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release:
r290 (1.1 Milestone 1)

Detailed description:
If you try to create a database that already exists or query a non-existent
table, the 'execute()' method throws an exception, but it isn't a
DatabaseException.

I'm having a Firefox problem  (version 2.0.0.14), scenario:
- Execute page for the first time
- Enable Gears (popup)
- Check if database exist using a select statement -> DB_EXISTS (at
this time no database exist)
- statement just crashes, no error, just stopped working
- same scenario works perfectly in IE (damn, don't like saying that
one)
- I'm using milestone r290 (which I think is the latest one)
- When I 'cheat' and run the code te first time with the create
statement, change the code and run it with the select statement, all
is fine :-) But that is just cheating

Sample code from email:

 private static final String DB_EXISTS = "select name from
wishes where name = ?";
       private static final String DB_CREATE = "create table wishes
(name text not null primary key)";

       try {
           database = new Database();
           try {
               database.execute(DB_FETCH_NAMES);
           } catch (DatabaseException ex) {
               database.execute(DB_CREATE);
           }

Workaround if you have one:

You can perform a conditional create using the 'if not exists' syntax.

       private static final String DB_CREATE = "create table if not exists
wishes (name text not null primary key)";

Links to the relevant GWT Developer Forum posts:

http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thr
ead/4785ca66948d486

Original issue reported on code.google.com by galgwt.reviews@gmail.com on 12 May 2008 at 12:33

GoogleCodeExporter commented 9 years ago

Original comment by galgwt.reviews@gmail.com on 12 May 2008 at 12:34

GoogleCodeExporter commented 9 years ago
In firebug, I see the following message:

SQLite prepare() failed. ERROR: SQL logic error or missing database DETAILS: 
table
notes already exists EXPRESSION: create table notes (noteid text not null 
primary
key, version text not null, content text not null)
[Break on this error] undefined

But I don't get my alerts called.  Here is an example from a modified version 
of the
GWTNote sample code:

 private static final String DB_CREATE = "create table notes ("
    + "noteid text not null primary key, version text not null, "
    + "content text not null)";

    try {
      db = new Database();
       try {
        ResultSet r = db.execute(DB_CREATE);
        Window.alert("Create went pretty good." + (r == null ? "<null>" : r.toString()));

        if (r != null) {
          r.close();
        }
      } catch (DatabaseException dbEx) {
        // Creating a database more than once should not throw an exception.
        Window.alert("Exception creating database: " + dbEx.getMessage());
        // fall through
      } catch (Throwable t) {
        Window.alert("Exception creating database: " + t.getMessage());
        // fall through
      } 

Original comment by galgwt.reviews@gmail.com on 12 May 2008 at 3:55

GoogleCodeExporter commented 9 years ago
A bit of debugging with bobv:  The problem appears to be related to Firefox.  
Running some tests on InternetExplorer, the alert boxes show up where I expect 
them.

One suggestion from Bob, was to move the exception handling into the JSNI
nativeExecute() method and then create a Java DatabaseException object there. 
Looking at the generated code, it would be easy for the JavaScript compiled 
version
to 'miss' when doing a comparison by type.

Original comment by galgwt.reviews@gmail.com on 12 May 2008 at 4:59

GoogleCodeExporter commented 9 years ago
The attached patch updates the DatabaseTest class.  When you run this test on
Firefox, the testDoubleCreate() method hangs indefinitely.

Original comment by galgwt.reviews@gmail.com on 13 May 2008 at 2:07

Attachments:

GoogleCodeExporter commented 9 years ago
Tried to reproduce this test case in pure JavaScript outside of GWT.  I can't 
make it
fail in Firefox for Mac or Linux.

Original comment by ericzun...@gmail.com on 15 May 2008 at 1:37

Attachments:

GoogleCodeExporter commented 9 years ago
I just found that if I move the database initialization code outside of
onModuleLoad() that I can catch the exceptions as usual.

Original comment by ericzun...@gmail.com on 15 May 2008 at 6:53

GoogleCodeExporter commented 9 years ago
After some emails to the Gears project, they suggesed I file an issue.  See 
issue 504
in the Gears project:

http://code.google.com/p/google-gears/issues/detail?id=504

Original comment by galgwt.reviews@gmail.com on 21 May 2008 at 9:51

GoogleCodeExporter commented 9 years ago
The Gears team will notify us when they make a determination, in the mean time, 
no
action is needed by the GWT team.

Original comment by galgwt.reviews@gmail.com on 18 Jun 2008 at 7:51

GoogleCodeExporter commented 9 years ago

Original comment by galgwt.reviews@gmail.com on 18 Jun 2008 at 7:51

GoogleCodeExporter commented 9 years ago
s/b fixed in the next release of Google Gears:

Issue 504: Using Database execute method in some contexts results in an 
uncatchable
exception
http://code.google.com/p/gears/issues/detail?id=504

Comment #2 by zboogs:
I verified this in 0.3.21.0 and 0.3.24.0, but it is fixed in trunk. Not sure 
when it
happened.

Issue attribute updates:
       Status: Fixed

Original comment by galgwt.reviews@gmail.com on 30 Jun 2008 at 1:03

GoogleCodeExporter commented 9 years ago
This is not a GWT problem.  It should be addressed in the next Gears push.

Original comment by mmendez+personal@google.com on 23 Jul 2008 at 3:19

GoogleCodeExporter commented 9 years ago

Original comment by zundel@google.com on 21 Dec 2009 at 1:22

GoogleCodeExporter commented 9 years ago

Original comment by zundel@google.com on 21 Dec 2009 at 1:24