Heikki Tuuri wrote:
> ----- Original Message -----
> From: "rcandersonmn"
> Newsgroups: mailing.database.mysql
> Sent: Thursday, October 31, 2002 4:23 PM
> Subject: Prepared Statement Problem
> >I'm new to MySQL and am having problems with Prepared Statements in
> >MySQL. I'm using the latest MySQL beta version, Innodb, and the latest
> >JDBC driver. Here is what I'm trying to do:
> >Connection con = x.getConnection(); /* gets the connection
> >PreparedStatement ps = con.prepareStatement(sql); /* set up prepared
> >x.bindExampleWhere(ps, example); /* sets the preparedstatement's
> >ResultSet rs=ps.executeQuery();
> >The SQL is:
> >select * from Vendor
> >where (Vendor.agreement_id = ?)
> >The BindExample will produce:
> >The result set is always empty. When I run the query directly, I get
> >the expected result.
You don't say how you determine the result set is empty, which might be
where your problem is. Also, I would like to see what the code in
".bindExampleWhere()" actually does.
> If you are running with
> SET AUTOCOMMIT = 0
> and inserted the row during the current read transaction, then it
> might also
> be that you are reading too old a snapshot. The transaction doing the
> can issue a COMMIT to refresh the snapshot.
Heikki has a good point here, as this confuses many people who are not
used to using transactions under a REPEATABLE_READ isolation level.
I haven't replied to the original sender, as his e-mail has been
stripped from the original mail :(
For technical support contracts, visit https://order.mysql.com/?ref=mmma
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mark Matthews <mark@stripped>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
/_/ /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA