-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tea Yu wrote:
> Hi!  I just tried
>     Windows ME + MySQL Server - 4.0.9/4.0.11 +
>     ConnectorJ - 3.0.4/3.0.6/3.1.0
> 
> with an InnoDB table
>     test (id bigint not null auto_increment, name varchar(255))
> also tried
>     test (id int not null auto_increment, name varchar(255))
> 
> and did an SQLQuery thru JDBC
>     insert into TABLE (name) values ('test');
>     select last_insert_id() from TABLE;
> 
> but got the Exception
>     java.sql.SQLException: Invalid value for getInt() - 'q'
> 
> while successive running of program returns
>     'r', 's', 't'...
> 
> Query from console returns the correct result, but it returns n rows in set
> if last_insert_id() is n
> e.g. if select last_insert_id() = 7, 7 rows are returned in set
> 
> 
> Is there a bug in ConnectorJ regarding this... seems nobody else is having
> such a problem...?


I can't reproduce this error with the following test:

 public void testLastInsertId() throws Exception {
        try {
                stmt.executeUpdate("DROP TABLE IF EXISTS lastInsertTest");
                        stmt.executeUpdate("CREATE TABLE lastInsertTest (id bigint not 
null
auto_increment primary key, name varchar(255))");
                        stmt.executeUpdate("INSERT INTO lastInsertTest (name) values 
('test')");
                        rs = stmt.executeQuery("SELECT LAST_INSERT_ID() FROM 
lastInsertTest");
                        rs.next();
                        rs.getInt(1);
                        
                
        } finally {
                stmt.executeUpdate("DROP TABLE IF EXISTS lastInsertTest");
        }
    }

However, your SQL is a little funny, for example you can't create a
table using the SQL you give, as AUTO_INCREMENT columns also have to be
the primary key. Also, you call the table 'test', but then refer to it
as 'TABLE' when doing your SELECT_LAST_INSERT_ID()...so hopefully these
are cut-and-paste errors, otherwise it seems you are not creating the
queries you think you are.


- -- 
MySQL 2003 Users Conference -> http://www.mysql.com/events/uc2003/

For technical support contracts, visit https://order.mysql.com/?ref=mmma

    __  ___     ___ ____  __
   /  |/  /_ __/ __/ __ \/ /  Mark Matthews <[EMAIL PROTECTED]>
  / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer - JDBC/Java
 /_/  /_/\_, /___/\___\_\___/ Flossmoor (Chicago), IL USA
        <___/ www.mysql.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.1.90 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+X2wntvXNTca6JD8RApMYAJ4sHFs2ClyJAMUiUcqs0F9nkzS8WQCgvqfO
wK/abVjxu31u8Uyveq1gk48=
=VBbn
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
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