You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bl...@aol.com on 2001/09/23 02:44:35 UTC

New To Java - Cant't get Database Insert to work

Hello All,

I am trying to insert two values into a access database from a Servlet. The 
values are form variables consisting of  a URL and a name. I'm  getting the 
following error:

SQL Exception Caught: [Microsoft][ODBC Microsoft Access Driver] Syntax error 
in INSERT INTO statement.  

If anyone can help with this I appreciate it very much.  I have attached the 
Servlet source code.

Thanks,
Brian  

Re: New To Java - Cant't get Database Insert to work

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
Hi,

A better way to do this would be to use prepared statements:

PreparedStatement pstmt = con.prepareStatement(
   "insert into LINKS (VALUE, NAVIGATION_TEXT) values(?,?))";
pstmt.setString(1, url);
pstmt.setString(2, favName);
pstmt.executeUpdate();

I'm not sure what is wrong with your sql... try inserting it manually
using your preferred sql client and see how you go.

cheesr
dim

On Sat, 22 Sep 2001 BlyonsJ2EE@aol.com wrote:

> Hello All,
> 
> I am trying to insert two values into a access database from a
> Servlet. The values are form variables consisting of a URL and a name.
> I'm getting the following error:
> 
> SQL Exception Caught: [Microsoft][ODBC Microsoft Access Driver] Syntax
> error in INSERT INTO statement.
> 
> If anyone can help with this I appreciate it very much.  I have
> attached the Servlet source code.
> 
> Thanks, Brian
>