> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Tea Yu wrote:
> > Hi there!
> >
> > Sorry, cause I didn't copy-n-paste those so there were typos, actually I
> > created the table in console:
> >
> > 1) create table test (id INTEGER NOT NULL AUTO_INCREMENT, name
VARCHAR(255),
> > primary key (id));
> >
> > 2) here is the code segment
> >
> >   String insertStmt = "insert into test (name) values ('hi')";
> >   String queryStmt = "select last_insert_id()";
> >
> >   try {
> >    stmt.executeUpdate(insertStmt);
> >    ResultSet rs = stmt.executeQuery(queryStmt);
> >    if(rs.next())
> >     System.out.println("last insert id: " + rs.getInt(1));
> >   } catch (SQLException e) {
> >    System.out.println(e);
> >   }
> >
> > if
> > a) I comment out the rs.getInt(1) line, no exception throws... else it
> > throws something like
> >     java.sql.SQLException: Invalid value for getInt() - 't'
> > b) if I use getString(1) instead, no exception throws...
> >     but it returns "t", "u" or something
> >
> > 3) I tried to insert records thru MySQLCC without errors.
> >
> > More thoughts?
> >
> > Regards
> > Tea
>
> The only thing I can guess (because my testsuite is really the same
> code, I just don't store the queries in variables), is that 'queryStmt'
> does not hold the query you think it does. Try inspecting it in a
> debugger or printing it out before you execute the query, to see what
> query you are really executing.
>
> -mark

Not really, I substituted the queryStmt with the actual one but it gave the
same result.

After some work:

select last_insert_id();    //getInt() should return 14
                                    //but now it gives
java.sql.SQLException: Invalid value for getInt() - 'qt'
 at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1348)

where thisRow([0]) that ResultSet holds was = (49, 52)

I haven't looked deeper into ResultSet and StringUtils... Is this as
expected?

My platform is WinME and my JRE is 1.4.1_01

thanks
tea


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