Just a gee-wiz question: Is it any more efficient (database wise or code
wise) to update it using an updateable ResultSet? I use this type of
thing all the time:
Statement Stmt = Conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = Stmt.executeQuery("select columns from table where
return='empty result set'");
rs.moveToInsertRow();
rs.updateInt("MyIntCol", iInt);
rs.updateString("MyStringCol", StringVariable);
rs.insertRow();
rs.close();
Doing this, the JDBC driver handles the escaping for me as well. I'm
just curious which one is 'better'.
Any opinions?
Jared W.
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]] On Behalf Of Joseph Ottinger
Sent: Thursday, September 05, 2002 7:51 AM
To: [EMAIL PROTECTED]
Subject: Re: JSP Apostrophe in JDBC
As I've been suggesting on the list (two times? three times? all in the
last
24 hours!), use PreparedStatement. It looks like this:
PreparedStatement ps=conn.
prepareStatement("insert into tablename values (?,?,?)");
ps.setString(1, "O'Donnell"); // correctly escaped
ps.setTimestamp(2, new Timestamp(myDate.getTime()));
ps.setInt(3, 4);
ps.executeUpdate();
I'm typing from memory and a bit blurry, so some method names may be
incomplete but note how much work I put into converting the apostrophes,
and
how hard I had to try to get the date formatted properly. For any
compliant
JDBC driver, this code will work as intended, and I didn't have to do
anything for it. Welcome to Java.
>From: Benoit Jodoin <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: JSP Apostrophe in JDBC
>Date: Thu, 5 Sep 2002 09:10:25 -0400
>
>It's a solution i've found...what would you suggest?..how do you let
the
>driver do it?
>
>At 05:33 AM 9/5/2002 -0500, you wrote:
>>Works just fine for YOU, with SQL Server. Other DBs don't do the same
>>thing
>>(although most do) and it's slower than letting the DB driver do it.
>>
>>
>>>From: Benoit Jodoin <[EMAIL PROTECTED]>
>>>Reply-To: A mailing list about Java Server Pages specification and
>>>reference <[EMAIL PROTECTED]>
>>>To: [EMAIL PROTECTED]
>>>Subject: Re: JSP Apostrophe in JDBC
>>>Date: Thu, 5 Sep 2002 01:14:45 -0400
>>>
>>>Try replacing your single quote with 2 single quotes..works just fine
for
>>>me with sqlserver.
>>>
>>>Regards
>>>
>>>Ben
>>>
>>>At 01:12 AM 9/5/2002 -0400, you wrote:
>>>>[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer] Line 1:
Incorrect
>>>>syntax near 's'.
>>>>
>>>>----- Original Message -----
>>>>From: "Benoit Jodoin" <[EMAIL PROTECTED]>
>>>>To: <[EMAIL PROTECTED]>
>>>>Sent: Wednesday, September 04, 2002 11:36 PM
>>>>Subject: Re: JSP Apostrophe in JDBC
>>>>
>>>>
>>>> > Can you give us your error msg plz?:)
>>>> >
>>>> > At 11:33 PM 9/4/2002 -0400, you wrote:
>>>> > >I am getting an error when updating some input text records
using a
>>>>form
>>>> > >
>>>> > >When I enter an Apostrophe in the text fields and send to the
jsp
>>>>page
>>>> > >which update the record in the db, it causes an error on the sql
>>>>jdbc
>>>>call.
>>>> > >
>>>> > >How do you treat Apostrophe in jsp, esp when sql is involved ?
>>>> > >
>>>> > >
>>>> > >To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>>>> > >JSP-INTEREST".
>>>> > >For digest: mailto [EMAIL PROTECTED] with body: "set
>>>>JSP-INTEREST
>>>>DIGEST".
>>>> > >Some relevant FAQs on JSP/Servlets can be found at:
>>>> > >
>>>> > > http://archives.java.sun.com/jsp-interest.html
>>>> > > http://java.sun.com/products/jsp/faq.html
>>>> > > http://www.esperanto.org.nz/jsp/jspfaq.jsp
>>>> > > http://www.jguru.com/faq/index.jsp
>>>> > > http://www.jspinsider.com
>>>> >
>>>> >
>>>>====================================================================
=======
>>>> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>>>>JSP-INTEREST".
>>>> > For digest: mailto [EMAIL PROTECTED] with body: "set
JSP-INTEREST
>>>>DIGEST".
>>>> > Some relevant FAQs on JSP/Servlets can be found at:
>>>> >
>>>> > http://archives.java.sun.com/jsp-interest.html
>>>> > http://java.sun.com/products/jsp/faq.html
>>>> > http://www.esperanto.org.nz/jsp/jspfaq.jsp
>>>> > http://www.jguru.com/faq/index.jsp
>>>> > http://www.jspinsider.com
>>>>
>>>>====================================================================
=======
>>>>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>>>>JSP-INTEREST".
>>>>For digest: mailto [EMAIL PROTECTED] with body: "set
JSP-INTEREST
>>>>DIGEST".
>>>>Some relevant FAQs on JSP/Servlets can be found at:
>>>>
>>>> http://archives.java.sun.com/jsp-interest.html
>>>> http://java.sun.com/products/jsp/faq.html
>>>> http://www.esperanto.org.nz/jsp/jspfaq.jsp
>>>> http://www.jguru.com/faq/index.jsp
>>>> http://www.jspinsider.com
>>>
>>>=====================================================================
======
>>>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>>>JSP-INTEREST".
>>>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>>>DIGEST".
>>>Some relevant FAQs on JSP/Servlets can be found at:
>>>
>>>http://archives.java.sun.com/jsp-interest.html
>>>http://java.sun.com/products/jsp/faq.html
>>>http://www.esperanto.org.nz/jsp/jspfaq.jsp
>>>http://www.jguru.com/faq/index.jsp
>>>http://www.jspinsider.com
>>
>>
>>-----------------------------------------------
>>Joseph B. Ottinger [EMAIL PROTECTED]
>>http://enigmastation.com IT Consultant
>>
>>_________________________________________________________________
>>MSN Photos is the easiest way to share and print your photos:
>>http://photos.msn.com/support/worldwide.aspx
>>
>>======================================================================
=====
>>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>>JSP-INTEREST".
>>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>>DIGEST".
>>Some relevant FAQs on JSP/Servlets can be found at:
>>
>>http://archives.java.sun.com/jsp-interest.html
>>http://java.sun.com/products/jsp/faq.html
>>http://www.esperanto.org.nz/jsp/jspfaq.jsp
>>http://www.jguru.com/faq/index.jsp
>>http://www.jspinsider.com
>
>=======================================================================
====
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>http://archives.java.sun.com/jsp-interest.html
>http://java.sun.com/products/jsp/faq.html
>http://www.esperanto.org.nz/jsp/jspfaq.jsp
>http://www.jguru.com/faq/index.jsp
>http://www.jspinsider.com
-----------------------------------------------
Joseph B. Ottinger [EMAIL PROTECTED]
http://enigmastation.com IT Consultant
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
========================================================================
===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com