3 messages in com.googlegroups.google-gearsRe: [google-gears] Re: Using COMMIT o...
FromSent OnAttachments
ronald mathies25 Oct 2007 22:45 
Aaron Boodman26 Oct 2007 04:51 
ronald mathies26 Oct 2007 06:29 
Subject:Re: [google-gears] Re: Using COMMIT or not, closing ResultSet or not
From:ronald mathies (rona@gmail.com)
Date:10/25/2007 10:45:44 PM
List:com.googlegroups.google-gears

I am familiar with database so at least i now know that COMMIT goes along with the BEGIN statement to form a transaction. The ResultSet rs = null, rs2 = null; Is a combination of GWT (Google Web Toolkit) and Google Gears where the Google Gears part is an extra (Java) library.

http://wiki.oreade.nl/Wiki.jsp?page=GearsGWTLibrary

On 10/25/07, Aaron Boodman <a.@google.com> wrote:

On Oct 25, 2007 6:32 AM, Ronald Mathies <rona@gmail.com> wrote:

database.execute("commit");

But when i use this after my INSERT i get errors, my complete code is:

Looks like you are missing the BEGIN statement.

The "begin" and "commit" statements are used to create transactions. (If you're not familar with database transactions you can read about them on the web). Basically, they give you (simplifying dramatically here):

* atomicy -- if one thing inside the transaction fails, the whole transaction fails together

* performance -- if you do a bunch of inserts or updates, they will all be written together, when you run "commit", instead of one at a time. Since writes are slow, it makes sense to use transactions to batch them together.

ResultSet rs = null, rs2 = null;

What language is this? The JavaScript that Gears targets does not have typing (you'd use "var" instead of "ResultSet". It looks like maybe you're using Gears in some other environment. If so, can you give any more detail? It looks interesting!

And another question, since you have to perform all the actions using the Database.execute method, do i then always need to close the ResultSet? (even in the cases where i create a table, drop a table, perform a commit, delete all records from a table, etc...)

Technically, you only need to call close() when the statement returned rows. It doesn't hurt to call it in other cases, so it's best practice to always call it.

HTH,

- a