[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-java
Subject:    Re: Updatable ResultSet, why changed?
From:       Mark Matthews <mmatthew () thematthews ! org>
Date:       2002-06-28 13:31:20
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Javier Bolaņos Molina wrote:
| Hi everybody, I encountered that a program  of mine that worked
| correctly with mm.mysql 2.0.11 now refuses to work with 2.0.12 or above.
|
|
| The program basically re-enumerate the field "numero" from 1 to n for
| every distinct "folio"
|
| "folio" + "numero" constitute a primary key hence they are included in
| the SELECT statement as a requirement for a updatable resultset.
|
| Now given a particular "folio" the uprsActualizacionNumeroAnexo is
| iterated and each "numero" is replaced this occurs with
| uprsActualizacionNumeroAnexo.updateRow().
|
| This worked fine with mm.mysql 2.0.11, but now a exception is thrown
| tellin:
|
| java.sql.SQLException: refreshRow() called on row that has been deleted
| or had primary key changed
| 	at org.gjt.mm.mysql.jdbc2.ResultSet.refreshRow(Unknown Source)
| 	at org.gjt.mm.mysql.jdbc2.ResultSet.updateRow(Unknown Source)
| 	at
| reasignanumeroanexo.VentanaReasignacion.run(VentanaReasignacion.java:151)
|
|
|
| Maybe this adjust with JDBC Specification but if you have a suggestion
| how to reimplement this using the new mm.mysql drivers I'd be glad.
|
| Thank you.
|
|
|
|
| Here is the segment of code:
| -----------------------------------------------------------------------
|
| PreparedStatement stmtActualizacionNumeroAnexo = //Updatable statement
| 	conn.prepareStatement("SELECT folio, numero FROM anexo WHERE folio=?
| ORDER BY folio, fecha_registro, fecha_actualizacion",
| 	ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
| stmtActualizacionNumeroAnexo.clearParameters();
| stmtActualizacionNumeroAnexo.setInt(1, folio);
| ResultSet uprsActualizacionNumeroAnexo =
| 	stmtActualizacionNumeroAnexo.executeQuery();
|
| int nuevo_numero = Integer.MAX_VALUE;
|
| while(uprsActualizacionNumeroAnexo.next()){
| 	uprsActualizacionNumeroAnexo.updateInt("numero",nuevo_numero--);
| 	uprsActualizacionNumeroAnexo.updateRow();//<<-- throws exception
|       						 //<<-- with 2.0.13
| }
|
| uprsActualizacionNumeroAnexo.close();
|
| uprsActualizacionNumeroAnexo =
| 	stmtActualizacionNumeroAnexo.executeQuery();
|
| nuevo_numero = 1;
|
| while(uprsActualizacionNumeroAnexo.next()){
| 	noRegistros++;
| 	uprsActualizacionNumeroAnexo.updateInt("numero",nuevo_numero++);
| 	uprsActualizacionNumeroAnexo.updateRow();
| }
|
| uprsActualizacionNumeroAnexo.close();
|
- 
---------------------------------------------------------------------------

MM.MySQL has had some changes in it to make some things work better.
Result Sets now use refresh row to be able to read some values back when
updateRow() is called. If you change the primary key it fails. The
reason for this is that there is no way to identify a row in MySQL other
than primary key. It is not a usual practice to change the value of
primary keys (it goes against database best practices), so this bug was
not discovered until just a little while ago. I'm working on a fix, but
if you want it to work for now, you will have to go back to 2.0.11.

	-Mark



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6-2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAj0cZSgACgkQlyjUJM+7nP584wCeJXQG+uQxM8QUqgjIrtPK8BRP
1qcAniBVa31GmHkNFTBfLk/CL3SHndcz
=huAV
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail java-thread3925@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail java-unsubscribe@lists.mysql.com instead.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic