6 messages in com.mysql.lists.javaRe: SQL-Error if not row found| From | Sent On | Attachments |
|---|---|---|
| Helmut Leininger | 11 Sep 2004 10:13 | |
| Mark Matthews | 11 Sep 2004 11:20 | |
| Helmut Leininger | 12 Sep 2004 00:27 | |
| Mark Matthews | 13 Sep 2004 06:13 | |
| Helmut Leininger | 13 Sep 2004 11:20 | |
| Mark Matthews | 13 Sep 2004 11:26 |
| Subject: | Re: SQL-Error if not row found![]() |
|---|---|
| From: | Mark Matthews (ma...@mysql.com) |
| Date: | 09/13/2004 06:13:42 AM |
| List: | com.mysql.lists.java |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Helmut Leininger wrote:
Mark Matthews wrote:
| Helmut Leininger wrote: | |> Hi, | |> I have the following problem with connector 3.1.4-beta: | |> There is a table that contains an integer column, e.g. | |> numfld integer, charfld char(50) | |> Contents: | |> 1, 'row 1' 2, 'row 2' | | |> The importatnt lines in the program are: | |> int val; Statement s; | |> ... // select a row that does not exist ResultSet rs = |> s.executeQuery("select numfld from tab where numfld = | | 1234"); | |> if (rs.first() { // or rs.next() val = rs.getInt(1); } |> | |> I get an error like the following, both in using first() or |> next(): | |> java.sql.SQLException: '3.440462864E9' in column '1' is outside |> valid range for the datatype INTEGER | |> (The number changes). | | |> This does not happen using Connector 3.1.3-beta | | | Helmut, | | Perhaps you missed this bit in the CHANGES file (always important | to read when upgrading!): | | - The driver is more strict about truncation of numerics on | ResultSet.get*(), and will throw a SQLException when truncation is | detected. You can disable this by setting | 'jdbcCompliantTruncation' to false (it is enabled by default, as | this functionality is required for JDBC compliance). | | -Mark | | -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE | and Windows Platforms Office: +1 708 332 0507 www.mysql.com | | MySQL Guide to Lower TCO | http://www.mysql.com/it-resources/white-papers/tco.php
Mark,
I do not think this is the problem.
If no row is found, ResultSet.next() should (must) return false. So, there cannot be a numeric truncation because the ResultSet.get*() would not be executed.
Helmut,
I'm curious as to why ResultSet.next() isn't working for you then in this case. Do you have a _full_ testcase you can present?
(this scenario is actually already in the testsuite, so it must be something specific to your use case).
-Mark
- -- Mr. Mark Matthews MySQL AB, Software Development Manager, J2EE and Windows Platforms Office: +1 708 332 0507 www.mysql.com
MySQL Guide to Lower TCO http://www.mysql.com/it-resources/white-papers/tco.php -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBRZ0ctvXNTca6JD8RArlxAJwP51CI55ic90ryzrUwbaXknfsZMwCbBKen pNAhsqIGuFKeb+pE9sWc1dw= =bQ4q -----END PGP SIGNATURE-----




