From: | "Joel Hock" <joel(at)enspire(dot)com> |
---|---|
To: | "Dave Cramer" <Dave(at)micro-automation(dot)net> |
Cc: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: more insertRow() bugs and fixes |
Date: | 2003-02-05 15:41:32 |
Message-ID: | BNEGKPDJEODNGBJKPJBPGEOBCBAA.joel@enspire.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Sure thing-new diff is attached.
Thanks again,
Joel
-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org]On Behalf Of Dave Cramer
Sent: Wednesday, February 05, 2003 5:20 AM
To: Joel Hock
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] more insertRow() bugs and fixes
Joel,
Thanks for the code, I do have one request though, can you use the -c
switch on diff to produce a context diff, and resubmit please?
Dave
On Tue, 2003-02-04 at 18:17, Joel Hock wrote:
> First, a big thanks to Dave Cramer for working with me on the last
> insertRow() issue I had--the patch works wonderfully!
>
>
>
> Now, on to the next few things.
>
>
>
> 1. When you insert a row into a resultset that has no rows and then
> call moveToCurrentRow(), you get a null pointer exception. Example
> code:
>
>
>
> Statement stmt =
> con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
> ResultSet.CONCUR_UPDATABLE);
>
> ResultSet uprs = stmt.executeQuery("SELECT oid,* FROM school WHERE
> 1=0");
>
> uprs.moveToInsertRow();
>
> uprs.updateString("name", name);
>
> uprs.insertRow();
>
> uprs.moveToCurrentRow();
>
>
>
> java.lang.ArrayIndexOutOfBoundsException: -1 < 0
>
> at java.util.Vector.elementAt(Vector.java:437)
>
> at
>
org.postgresql.jdbc2.AbstractJdbc2ResultSet.moveToCurrentRow(AbstractJdbc2Re
sultSet.java:667)
>
>
>
> The cause of this is pretty straightforward. The offending line 667
> in AbstractJdbc2ResultSet.java is:
>
>
>
> this_row = (byte[][]) rows.elementAt(current_row);
>
>
>
> current_row is -1 because the current position is before any rows.
>
>
>
> 2. After moving onto the insert row, only a few of the resultset
> cursor-moving functions clear the internal ´onInsertRow¡ variable.
> According to
> http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/inserting.html
> :
>
> ´After you have called the method insertRow , you can start building
> another row to be inserted, or you can move the cursor back to a
> result set row. You can, for instance, invoke any of the methods that
> put the cursor on a specific row, such as first , last , beforeFirst ,
> afterLast , and absolute . You can also use the methods previous ,
> relative , and moveToCurrentRow.¡
>
>
>
> However, in the current driver, only first() and moveToCurrentRow()
> clear the onInsertRow flag. This causes problems when you later try
> to update a row in the same resultset. The functions that need to be
> modified that come to mind are: last(), beforeFirst(), afterLast(),
> absolute(), previous(), next(), and relative() (relative() uses
> absolute() internally, so Iÿve skipped putting any code in it).
>
>
>
> Iÿve included a patch to address these issues, but Iÿm still new to
> the codebase (and my directory isnÿt set up to compile), so itÿll need
> a good looking-over.
>
>
>
> Thanks again,
>
> Joel
>
>
>
> ______________________________________________________________________
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
--
Dave Cramer <Dave(at)micro-automation(dot)net>
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly
Attachment | Content-Type | Size |
---|---|---|
patch | application/octet-stream | 3.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Taylor | 2003-02-05 15:50:42 | Netbeans - JDBC Driver Class |
Previous Message | Daniel Serodio | 2003-02-05 15:38:05 | Re: how to unsubscribe |