473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ResultSet is from UPDATE. No Data.

I created a simple test case to reproduce the problem (also check Bug
#15500):

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
* Simple test program to reproduce bug
*
* @author David Linsin
* @version 0.1
* @since 0.1
*/
public class BugReproducer{
Connection con;
String importQuery = "SET FOREIGN_KEY_CHECKS = 1;DELETE FROM Category
WHERE
id=\'0205342903\';SET FOREIGN_KEY_CHECKS = 0;INSERT INTO Category
VALUES(\'d0450f050a0dfd8e00e6da7bda3bb07e\',\'0205 342903\',\'0000000000000000000
0000000000000\',\'\',\'0\');INSERT INTO Attribute
VALUES(\'d0450f050a0dfd8e00e6da7b00dfa3c5\',\'d045 0f050a0dfd8e00e6da7bda3bb07e\'
,\'eType\',\'machine\',null);SET FOREIGN_KEY_CHECKS = 1;";
String updateQuery = "SET FOREIGN_KEY_CHECKS = 1;DELETE FROM Attribute
WHERE
foreignuuid=\'d0450f050a0dfd8e00e6da7bda3bb07e\' AND name=\'eType\';SET
FOREIGN_KEY_CHECKS = 0;INSERT INTO Attribute
VALUES(\'d0563ba70a0dfd8e01df43e22395b352\',\'d045 0f050a0dfd8e00e6da7bda3bb07e\'
,\'eType\',\'machine\',null);SET FOREIGN_KEY_CHECKS = 1;";
String bugQuery = "SELECT name,value FROM Attribute WHERE
foreignuuid=\'d0450f050a0dfd8e00e6da7bda3bb07e\'";

/**
* Sets up db connection and sets autocommit to false
*
* @throws Exception in case anything goes wrong during setup
*/
public BugReproducer() throws Exception {
Class.forName("com.mysql.jdbc.Driver");
// CONFIGURE YOUR DB PARAMETERS HERE
this.con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/jboss2?useUnicode=true&
characterEncoding=UTF8&allowMultiQueries=true","ro ot", "");
this.con.setAutoCommit(false);
}

/**
* Executes an update statment, closes statement
* and commits transaction.
* Closes connection.
*
* @throws Exception in case anything goes wrong
*/
public void testBug() throws Exception {
Statement stmt = this.con.createStatement();
stmt.executeUpdate(this.importQuery);
stmt.close();
this.con.commit();
this.con.close();
}

/**
* Executes an update statement and a query,
* reads first row of ResultSet which randomly leads to an SQLException.
* Closes statement and commits transaction.
* Closes connection.
*
* @throws Exception in case anything goes wrong
*/
public void testBug1() throws Exception {
Statement stmt = this.con.createStatement();
stmt.executeUpdate(this.updateQuery);
ResultSet rs = stmt.executeQuery(this.bugQuery);
// THIS IS WHERE THINGS GO WRONG
rs.next();
stmt.close();
this.con.commit();
this.con.close();
}

/**
* Creates two instances of BugReproducer class sequentially and calls
testBug()
* resp. testBug2(). This happens in loop which should lead to an
SQLException
with
* error message "ResultSet is from UPDATE. No Data."
*
* @param args unused
*/
public static void main(String[] args) {
int i = 0;
try {
for (i=0; i <= 5000; i++) {
BugReproducer one = new BugReproducer();
one.testBug();

BugReproducer two = new BugReproducer();
two.testBug1();

if (i%250 == 0) {
System.out.println("Count: " + i);
}
}
} catch (Exception e) {
System.out.println("Count: " + i);
e.printStackTrace();
}
}
}

Schema:

CREATE TABLE Category (
uuid char(32) NOT NULL,
id character varying(254),
parentuuid char(32),
name character varying(254),
sort integer,
PRIMARY KEY (uuid),
INDEX parentuuid (parentuuid),
INDEX id (id),
CONSTRAINT `parent_fk_1` FOREIGN KEY (`parentuuid`) REFERENCES
`Category`
(`uuid`) ON DELETE CASCADE
) CHARACTER SET utf8 ENGINE=InnoDB;

CREATE TABLE Attribute (
uuid char(32) NOT NULL,
foreignuuid char(32),
name character varying(254),
value character varying(254),
fid integer,
PRIMARY KEY (uuid),
INDEX foreignuuid (foreignuuid),
INDEX name (name(16)),
INDEX value (value(8)),
CONSTRAINT `attribute_fk_1` FOREIGN KEY (`foreignuuid`) REFERENCES
`Category` (`uuid`) ON DELETE CASCADE
) CHARACTER SET utf8 ENGINE=InnoDB;
--- In reply to ---
Hey there,

I have a probleme executing a query using a PreparedStatement, it
results in a SQLException with the message "ResultSet is from UPDATE.
No Data.". Below I added the profiler log which indicates that the
statement-id changed between [PREPARE] and [QUERY]. Shouldn't it be
[PREPARE] and [EXECUTE] anyway?

INFO: Profiler Event: [PREPARE] at
org.jboss.resource.adapter.jdbc.BaseWrapperManaged Connection.prepareStatement(BaseWrapperManagedConn ection.java:360)
duration: 62 ms, connection-id: 0, statement-id: 43, resultset-id: -1,
message: SELECT name,value FROM Attribute WHERE foreignuuid=?
2006-09-18 10:47:30,176 INFO [STDOUT] (Timer-4) 18.09.2006 10:47:30 N/A
N/A
INFO: Profiler Event: [QUERY] at
org.jboss.resource.adapter.jdbc.WrappedPreparedSta tement.executeQuery(WrappedPreparedStatement.java: 296)
duration: 32 ms, connection-id: 0, statement-id: 44, resultset-id: 0,
message: SELECT name,value FROM Attribute WHERE
foreignuuid='c01b997f0a0dfd8e018a4aeffbfeb45f'

I'm using JDK 1.5.0_06, mysql-connector-java-3.1.13-bin.jar with JBoss
4.0.2 and mysql 4.1.10 on W2K. I'm using JNDI to get a DataSource and
retrieve a Connection object.

Can anybody think of reason why the statement-id changes? Is this
change the reason for the SQLException mentioned above?

Thanks

David

Nov 3 '06 #1
0 6123

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RoyalScorpion | last post by:
hi guys, i get an updatable resultset from a connection then used it to insert a new row but the result set doesn't chane after insertion, i mean the no of rows before insertion is the same after...
3
by: Koen | last post by:
Hi, first of all, the machine setup server 1: - UDB2 7.2.5; COUNTRY=1, location = US, IBM1250 codepage - Locale: US English; Regional Settings: English; Keyboard: Dutch; decimal separator: ....
2
by: Twan Kennis | last post by:
Question: How do I pass a returning resultset from a nested Stored Procedure (which opens a cursor including option "WITH RETURN TO CALLER") as a returning resultset from it's own? When I...
0
by: David Linsin | last post by:
Hey there, I have a probleme executing a query using a PreparedStatement, it results in a SQLException with the message "ResultSet is from UPDATE. No Data.". Below I added the profiler log which...
3
by: Augustin Prasanna | last post by:
I need to display some 200 records (dynamic) on the screen.. I need to display records from 2 tables (one to many relationship) output would look like Customer Id Name Phone NO 1 abc ...
12
by: robertino | last post by:
Hi all, I've put together a few SPs to produce a BOM (bill of materials) listing, which together use a couple of global temp tables, and return the results from a cursor. Here's the code: ...
0
by: loken0673 | last post by:
Hello All I want to Split multirow resultset to single row, multicolumn resultset my table is ProfileDetail(ProfileId bigint, PropertyId bigint PropertyValue nvarchar(400)) Table data : ...
6
by: joerg | last post by:
Hello world, my program connects to a db2 database and needs to find out the column names and data types for a specific table. The code works fine with mysql and derby, but returns an empty...
0
by: wiser | last post by:
Hi, everyone. I have some problems with getting the data from ResultSet after executeQuery statement in Java. Here is my code: try { Statement statement = connection.createStatement();...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.