You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Randy <ra...@unitnet.com> on 2004/06/16 17:12:37 UTC

Help moving from a ConnectionBroker to using Tomcats DB Connection pool

Hello,

I need a little help

Hopefully I can give the info needed.

My servlets have been using this code I found a long time ago called
"DbConnectionBroker"

It works very well.

I have been trying to move to the db connection pool of tomcat.

They both use org.gjt.mm.mysql.Driver

But here is where I am having problems. Hopefully this little piece of code
is enough to help

The thing that is different is the connection I get from the
DbConnectionBroker is different that the one I get from 

/////
//this is what I do to use jndi
 ds = (DataSource)ctx.lookup(JNDICONTEXTLOOKUP);
 conn = ds.getConnection();
/////

So I guess my question is, is someone using JNDI with mysql and getting the
LastInsertID..

When I use the connection broker this piece of code below works fine, but
when I use it with jndi the line long newKey =
((org.gjt.mm.mysql.Statement)stmt).getLastInsertID() ;
Gets a class cast exception


Thanks for any help.......


try{
    	    Statement stmt = conn.createStatement();
    	    int ret = stmt.executeUpdate(ustr);
    	    rowsProcessed = ret;
    	    if ( ret == 0 ){
    		    writeErrorInfo(userID,"executeSql",
    					 "executeSql Failed - non fatal
error , no rows processed",
    					 "no rows processed",-1);
    		    stmt.close();
    		    return -1;
    	    }
          long newKey = ((org.gjt.mm.mysql.Statement)stmt).getLastInsertID()
;
    	    stmt.close();
          return (int)newKey;
}catch (SQLException e){



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org