Ryan,

----- Original Message -----
From: "rcandersonmn" <[EMAIL PROTECTED]>
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
> statement
>
> x.bindExampleWhere(ps, example); /* sets the preparedstatement's
> variables
>
> ResultSet rs=ps.executeQuery();
>
>
> The SQL is:
> select * from Vendor
> where (Vendor.agreement_id = ?)
>
> The BindExample will produce:
> (1,'1001')
>
>
> The result set is always empty. When I run the query directly, I get
> the expected result.

you should add the line

log

to the [mysqld] section of my.cnf and restart mysqld. That way you get the
General query log file 'hostname'.log to the datadir of MySQL. From it you
see what the server actually received from the client.

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 SELECT
can issue a COMMIT to refresh the snapshot.

As a sidenote, I just 2 hours ago updated
http://www.innodb.com/ibman.html#InnoDB_transaction_model to reflect the new
isolation level READ COMMITTED in 4.0.5. That level more closely emulates
Oracle, and every consistent read always opens a new snapshot. No need to
COMMIT any more to get a fresh snapshot if you do

SET [SESSION | GLOBAL] TRANSACTION ISOLATION LEVEL READ COMMITTED

READ COMMITTED will thus help in porting applications from Oracle to MySQL.

> This code worked when going against an Oracle Database.
>
> Any advice would be appreciated.
>
> -Ryan

Best regards,

Heikki Tuuri
Innobase Oy
---
InnoDB - transactions, hot backup, and foreign key support for MySQL
See http://www.innodb.com, download MySQL-Max from http://www.mysql.com

sql query




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to