Greg,
I tried your code and it works fine on my system. I'm using MySQL, Apache,
and Tomcat. The only thing different that I did was to close the statement
and the connection after the executeUpdate().
pstmt.close();
conn.close();
I can send you the servlet if you'd like, but it uses the same code you posted.
-Richard
At 02:20 PM 8/30/01 -0500, you wrote:
>This issue I posted about 10 days ago, and havent had a chance to jump
>back on this project until now... Still having trouble, I appreciate all
>your help... I am trying out a prepared statement now, but I am
>stuck. According to the advice on this wonderful list, this prepared
>statement should work for me. Problem is... I am not familiar with the
>concept of a prepared statement... this is what I've got:
>
><%
> Connection c = null;
> // Do the connection code first
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> String url="jdbc:odbc:afdallas";
> Connection con=DriverManager.getConnection(url, "username", "password");
> try {
> PreparedStatement pstmt = c.prepareStatement("INSERT INTO news
> (newsletter_ID, heading, entry, enteredby) VALUES (?, ?, ?, ?) ");
>
>pstmt.setInt(1,Integer.parseInt(request.getParameter("newsletter_ID").trim())
>);
> pstmt.setString(2, request.getParameter("heading").trim() );
> pstmt.setString(3, request.getParameter("entry").trim() );
> pstmt.setString(4, request.getParameter("enteredby").trim() );
> pstmt.executeUpdate();
> } catch(Exception exc) {
>
> }
>%>
>
>Could the problem be that I am not releasing the connection... and if
>so... How do I release the connection? This code doesnt error out, it
>just doesnt do the insert!
>Using SQL Server, Jrun, Windows...
>Thanks for all your help
>Greg Price
>
>----- Original Message -----
>From: <mailto:[EMAIL PROTECTED]>Clayton Nash
>To: <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
>Sent: Monday, August 20, 2001 12:00 PM
>Subject: Re: SQL Server Memo insert
>
>Use a prepared statement -- it'll take care of all those details for you
>-- I don't know how the tablib you're using will support it but that's the
>easiest and correct way to go.
>
>Clayton
>
>----- Original Message -----
>From: <mailto:[EMAIL PROTECTED]>Gregory Price
>To: <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
>Sent: Monday, August 20, 2001 4:54 PM
>Subject: Re: SQL Server Memo insert
>
>Nope, thanks for your response, but that doesnt work either! Let me know
>if anyone has any ideas.
>Thanks
>Greg
>
>----- Original Message -----
>From: <mailto:[EMAIL PROTECTED]>Jon Garry
>To: <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
>Sent: Monday, August 20, 2001 10:45 AM
>Subject: Re: SQL Server Memo insert
>
>Hi Gregory,
>
>I think you need to replace the ' (apostrophe) character with a '' (double
>apostrophe) before you insert the string into your db
>and it should work fine.
>
>Jon
>
>-----Original Message-----
>From: Gregory Price [mailto:[EMAIL PROTECTED]]
>Sent: 20 August 2001 16:26
>To: <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
>Subject: SQL Server Memo insert
>
>
>
>Hello, I am running Jrun and have run into a problem submitting a long
>string.
>The long string a user submits will likely be in French,
>which means a lot of single and double quotes. I am
>now able to submit this field under normal circumstance, but my code is
>choking on these characters... I bet you guys can nail this one pretty
>quick... I must need a function when I set that large string as a
>variable... Your help is very much appreciated. code is below:
>
><%@ taglib uri="jruntags" prefix="jrun" %>
>
><% String news_ID= request.getParameter("news_ID"); %>
><% String newsletter_ID= request.getParameter("newsletter_ID"); %>
><% String heading= request.getParameter("heading"); %>
><% String entry= request.getParameter("entry"); %>
><% String enteredby=request.getParameter("enteredby"); %>
><% String newslettermonth= request.getParameter("newslettermonth"); %>
><% String newsletteryear= request.getParameter("newsletteryear");
> String sqlQuery = "INSERT INTO news (newsletter_ID, heading, entry,
>enteredby) VALUES ("
> +newsletter_ID + ", '"
> +heading+ "', '"
> +entry+"', '"
> +enteredby+"')"; %>
>
>
>
>
>
><%--INSERT NEWSITEM--%>
> <jrun:sql datasrc="afdallas" id="allnews">
> <%=sqlQuery%>
> </jrun:sql>
>
>
>
>
>
>Thanks
>Greg Price
>
>
>
>----------------------DISCLAIMER-----------------------
>The information contained in this e-mail and any files
>transmitted with it are confidential and intended for
>the addressee only. No other person is authorised to
>copy, forward, disclose, distribute or retain this
>email in any form. If you have received this e-mail in
>error please notify the originator or send an e-mail to
>[EMAIL PROTECTED] This e-mail and any
>associated attachments have been scanned for viruses
>prior to dispatch, however Emap Performance and its
>subsidiary companies accept no liability for any losses
>resulting from infected e-mail transmissions.
>
>Please note any views expressed may be those of the
>originator and do not necessarily reflect those of this
>organisation.
>--------------------------------------------------------
>
>
>----------
>Hi Gregory,
>
>I think you need to replace the ' (apostrophe) character with a '' (double
>apostrophe) before you insert the string into your db
>and it should work fine.
>
>Jon
>-----Original Message-----
>From: Gregory Price [mailto:[EMAIL PROTECTED]]
>Sent: 20 August 2001 16:26
>To: [EMAIL PROTECTED]
>Subject: SQL Server Memo insert
>
>Hello, I am running Jrun and have run into a problem submitting a long
>string.
>The long string a user submits will likely be in French,
>which means a lot of single and double quotes. I am
>now able to submit this field under normal circumstance, but my code is
>choking on these characters... I bet you guys can nail this one pretty
>quick... I must need a function when I set that large string as a
>variable... Your help is very much appreciated. code is below:
>
><%@ taglib uri="jruntags" prefix="jrun" %>
>
><% String news_ID= request.getParameter("news_ID"); %>
><% String newsletter_ID= request.getParameter("newsletter_ID"); %>
><% String heading= request.getParameter("heading"); %>
><% String entry= request.getParameter("entry"); %>
><% String enteredby=request.getParameter("enteredby"); %>
><% String newslettermonth= request.getParameter("newslettermonth"); %>
><% String newsletteryear= request.getParameter("newsletteryear");
> String sqlQuery = "INSERT INTO news (newsletter_ID, heading, entry,
>enteredby) VALUES ("
> +newsletter_ID + ", '"
> +heading+ "', '"
> +entry+"', '"
> +enteredby+"')"; %>
>
>
>
>
>
><%--INSERT NEWSITEM--%>
> <jrun:sql datasrc="afdallas" id="allnews">
> <%=sqlQuery%>
> </jrun:sql>
>
>
>Thanks
>Greg Price
===========================================================================
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://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets