473,545 Members | 2,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ResultSet is from UPDATE. No Data.

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

import java.sql.Connec tion;
import java.sql.Driver Manager;
import java.sql.Result Set;
import java.sql.Statem ent;

/**
* 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_CHE CKS = 1;DELETE FROM Category
WHERE
id=\'0205342903 \';SET FOREIGN_KEY_CHE CKS = 0;INSERT INTO Category
VALUES(\'d0450f 050a0dfd8e00e6d a7bda3bb07e\',\ '0205342903\',\ '00000000000000 00000
0000000000000\' ,\'\',\'0\');IN SERT INTO Attribute
VALUES(\'d0450f 050a0dfd8e00e6d a7b00dfa3c5\',\ 'd0450f050a0dfd 8e00e6da7bda3bb 07e\'
,\'eType\',\'ma chine\',null);S ET FOREIGN_KEY_CHE CKS = 1;";
String updateQuery = "SET FOREIGN_KEY_CHE CKS = 1;DELETE FROM Attribute
WHERE
foreignuuid=\'d 0450f050a0dfd8e 00e6da7bda3bb07 e\' AND name=\'eType\'; SET
FOREIGN_KEY_CHE CKS = 0;INSERT INTO Attribute
VALUES(\'d0563b a70a0dfd8e01df4 3e22395b352\',\ 'd0450f050a0dfd 8e00e6da7bda3bb 07e\'
,\'eType\',\'ma chine\',null);S ET FOREIGN_KEY_CHE CKS = 1;";
String bugQuery = "SELECT name,value FROM Attribute WHERE
foreignuuid=\'d 0450f050a0dfd8e 00e6da7bda3bb07 e\'";

/**
* 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.g etConnection("j dbc:mysql://localhost:3306/jboss2?useUnico de=true&
characterEncodi ng=UTF8&allowMu ltiQueries=true ","root", "");
this.con.setAut oCommit(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.create Statement();
stmt.executeUpd ate(this.import Query);
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.create Statement();
stmt.executeUpd ate(this.update Query);
ResultSet rs = stmt.executeQue ry(this.bugQuer y);
// 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.prin tln("Count: " + i);
}
}
} catch (Exception e) {
System.out.prin tln("Count: " + i);
e.printStackTra ce();
}
}
}

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 PreparedStateme nt, 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.resou rce.adapter.jdb c.BaseWrapperMa nagedConnection .prepareStateme nt(BaseWrapperM anagedConnectio n.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.resou rce.adapter.jdb c.WrappedPrepar edStatement.exe cuteQuery(Wrapp edPreparedState ment.java:296)
duration: 32 ms, connection-id: 0, statement-id: 44, resultset-id: 0,
message: SELECT name,value FROM Attribute WHERE
foreignuuid='c0 1b997f0a0dfd8e0 18a4aeffbfeb45f '

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 6148

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

Similar topics

0
3636
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 insertion and also the data, this is the code prove what i say int currentRow = resultset.getRow(); display(resultset);...
3
4208
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: . server 2: - UDB2 7.2.5 Client Tools - Websphere 4.0.5
2
10590
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 execute the top-level Stored Procedure, it executes succesfully, but without any resultset. ==========================================================...
0
1576
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 indicates that the statement-id changed between and . Shouldn't it be and anyway? INFO: Profiler Event: at
3
2173
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 23949495 34945959
12
2167
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: -- Initialize the temp tables............ create procedure myschema.init_ebom_tables ( ) language sql
0
1632
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 : ProfileId PropertyId PropertyValue 97 1 lokendra
6
9974
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 resultset for the table's metadata with db2. SELECTs on the connection object work, so there is no problem with the database connection.
0
1142
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(); String query = "select CITY, SHORT_NAME from airports"; ResultSet rs = statement.executeQuery(query); Vector...
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7778
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6003
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.