3 messages in com.mysql.lists.javaRE: SQLException caught: Before start...| From | Sent On | Attachments |
|---|---|---|
| David Nardini | 25 Mar 2001 04:20 | |
| Filip Hanik | 25 Mar 2001 07:33 | |
| David Nardini | 25 Mar 2001 10:11 |
| Subject: | RE: SQLException caught: Before start of result set![]() |
|---|---|
| From: | Filip Hanik (ma...@filip.net) |
| Date: | 03/25/2001 07:33:40 AM |
| List: | com.mysql.lists.java |
first, you should close any previous results before executing the next query and then you need to scroll to the first row of the result set; change these lines
----8<-------------
statement.setInt(5, sessionLightbox.getNumOfImages()); statement.execute();
to: statement.setInt(5, sessionLightbox.getNumOfImages()); statement.execute(); statement.close();
stat1.execute(); int iNextId = stat1.getResultSet().getInt("ID");
to: stat1.execute(); ResultSet rs = stat1.getResultSet(); if ( rs != null && rs.next() ) { int iNextId = rs.getInt("ID"); }
----8<-------------
let me know if this solves your problem Filip ~ Namaste - I bow to the divine in you ~ Filip Hanik Software Architect fil...@filip.net www.filip.net
-----Original Message----- From: David Nardini [mailto:dav...@speedpix.com] Sent: Sunday, March 25, 2001 4:21 AM To: ja...@lists.mysql.com Subject: SQLException caught: Before start of result set Importance: High
Hello,
Can somebody please advise why I get a : SQLException caught: Before start of result set.
Following is the code, and it fails performing the 'SELECT ..." (the INSERT works fine).
String sql = new String(); sql = "INSERT INTO LIGHTBOX (CLIENT_ID, LIGHTBOX_ID, NAME, TS, IMAGE_COUNT) VALUES (?, ?, ?, ?, ?)";
PreparedStatement statement = con.prepareStatement(sql); statement.setString(1, (String) session.getValue("clientID")); statement.setInt(2, 0); statement.setString(3, req.getParameter("lb_name").trim()); statement.setInt(4, 0); statement.setInt(5, sessionLightbox.getNumOfImages()); statement.execute();
PreparedStatement stat1 = con.prepareStatement("SELECT LAST_INSERT_ID() AS ID"); stat1.execute(); int iNextId = stat1.getResultSet().getInt("ID");
I've also tried using 'executeUpdate' and 'executeQuery' (respectively), again without success.
The environment is :
RedHat 6.2, MySQL 3.23, IBM JDK 1.3, JDBC = mm.jdbc-2.0.4.
Any advice appreciated.
David.
--------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail java...@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...@lists.mysql.com instead.




