Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Beans > Re: Obtaining S...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 1386 of 1403
Post > Topic >>

Re: Obtaining SQL insert auto generated key from query within JSP

by Damon Getsman <dgetsman@[EMAIL PROTECTED] > Sep 11, 2008 at 01:21 PM

Well, I guess I should specify that I'm using MySQL as the back end.

I managed to get JSP to keep the session open by wrapping the
<sql:insert> that I was talking about along with the <sql:query> in a
<sql:transaction> set (I think).  What I've got right now is basically

<sql:transaction dataSource=3D"${whatever}">
 <sql:insert>
   INSERT INTO blah
     (one, two, three)
   VALUES (?, ?, ?)
 ...the corresponding <sql:param ...> statements...
  </sql:insert>

  <sql:query var=3D"pId">
    SELECT LAST_INSERT_ID() FROM blah
  </sql:query>
</sql:transaction>

That particular jsp fragment crashed completely on me when I had the
semicolon after LAST_INSERT_ID(), so I removed it.

Now I'm getting back as a value for ${pId}:
org.apache.taglibs.standard.tag.common.sql.ResultImpl@[EMAIL PROTECTED]
 sure where to go from here, but I think you guys have helped me
get a little further...  Any other ideas?  (And it's all much
appreciated)

Damon Getsman
-=3D-=3D-
Programmer/Systems Administrator
ITRx - http://www.itrx-nd.com/
-=3D-=3D-

On Sep 11, 1:51=A0pm, Mark Space <marksp...@[EMAIL PROTECTED]
> wrote:
> I'm guessing here but probably something like:
>
> <sql:query>
> =A0 =A0select LAST_INSERT_ID();
> </sql:query>
>
> Do a search on that sql function, see what comes up. It's connection
> oriented so I'm hoping the JSP will maintain an open connection for ya.
 




 4 Posts in Topic:
Obtaining SQL insert auto generated key from query within JSP
Damon Getsman <dgetsma  2008-09-11 07:26:04 
Re: Obtaining SQL insert auto generated key from query within JS
Damon Getsman <dgetsma  2008-09-11 07:30:10 
Re: Obtaining SQL insert auto generated key from query within JS
Mark Space <markspace@  2008-09-11 11:51:43 
Re: Obtaining SQL insert auto generated key from query within JS
Damon Getsman <dgetsma  2008-09-11 13:21:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 23:48:57 CST 2008.