Re: PreparedStatement returns different result than regular Statement???
Posted by: s.a.w.gooren
Date: January 16, 2005 01:28PM

CREATE TABLE test(
id int(2),
guid varbinary(16)
);

INSERT INTO test(1, UNHEX(REPLACE(UUID(), _utf8"-", _utf8"")) );

When I run some java code:

// Case 1: regular connection:
ResultSet rs = statement.executeQuery("SELECT guid FROM test WHERE id=1");
byte[] bytes = rs.getBytes("guid");

// Case 2: preparedStatement
PreparedStatement ps = connection.prepare("SELECT guid FROM test WHERE id=?");
ps.setInt(1, 1);
ResultSet rs2 = ps.executeQuery();
byte[] bytes2 = rs.getBytes("guid");

On my systems bytes contains a different value from bytes2.
This problem did not exist in the 3.0.x driver, but after switching to 3.1.6 it was introduced. Setting "useServerPrepStmts=false" obviously fixes it, but it's not really a solution.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.