Re: PreparedStatement returns different result than regular Statement???
Posted by: Mark Matthews
Date: January 20, 2005 09:20AM

s.a.w.gooren wrote:
> id int(2),
> guid varbinary(16)
> );
> _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();

Maybe need an here?

> byte[] bytes2 = rs.getBytes("guid");

This should be rs2.getBytes(), I'm assuming?
> 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.

I just tested with 3.1.6 and MySQL-4.1.8 and I get the same values for both byte[]s.

Is there something else that could be affecting this (charsets for example, are you running with 'latin1' or something else?)


Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools

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.