with two browser windows open If I use a form hooked up to a servlet to add
a row to the table,
then access it with another browser window the data shows up fine, as I
would
expect it to, so I take it from this that that the data is automatically
committed to the table by the executeStatement() method.

I wasn't entering the table through another session before - I may not have
explained myself very clearly -  I was starting access and then opening the
table within access itself to see if the data had been entered.

I guess it boils down to the same thing tho, the data actually is committed
to the table by the executeStatement() method : )

thanks for the suggestion anyway

-----Original Message-----
From: Thomas Moorehead [mailto:[EMAIL PROTECTED]]
Sent: 08 May 2001 13:36
To: [EMAIL PROTECTED]
Subject: Re: SQL string


When you enter the table "manually" you are in fact entering another
session. It won't show up until you're other session (where you're doing the
update) does a commit. Check to see if  executeUpdate auto-commits. If so,
my suggestion is irrelevant...

-----Original Message-----
From: Paul Foxton [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 08, 2001 5:46 AM
To: [EMAIL PROTECTED]
Subject: Re: SQL string


Many thanks for all the replies.

Thomas:

I'm not using transactions for this, since its a test to make sure
I can get it to work. Theres only one statement to execute, so I shouldn't
need to use transactions at this stage? I was checking if the data had been
entered
by opening the table manually inside access.

Noel wrote:

>>Hi, Paul

>>Two points: 1) Don't you check for nulls in any of your request
parameters?
>>Even just one null can hose your SQL string.  2) Try using a
>>PreparedStatement.  Otherwise, fname values like "O'Reilly" will render
the
>>resulting SQL invalid.

>>Regards,
>>Noel Lecaros

thanks for the tips, not checking for nulls isn't the problem here,
but as I scale this up I will do. I'll also be stripping symbols out
the user input to ensure legal values - I'm just testing ATM.

Matt wrote:

>>        One of the easiest ways to debug SQL statements is to print the
final
>>statement to the output whether it is a web page, a text field, or the
>>command line.  I catch 90% of my errors this way.  Otherwise if you're
>>getting an exception print a stack trace, again to whatever output, and
let
>>us know what it returns.

>>        Matt

the SQL INSERT statement I included in the email was a printout of the SQL
statement generated
by the servlet to browser. This is how I catch most of my errors too : )

The db update is working fine now, but its one of those situations where
after
a bit of editing of the code it seemed to start working by itself.

John: I put the single quotes back into the statement and tried it again and
this time it
worked, so I assume I'd missed one out and messed up the statement the first
time round.

So in this case it looks like it was my old friend user error ;)

thanks again everyone,

Paul

-----Original Message-----
From: Thomas Moorehead [mailto:[EMAIL PROTECTED]]
Sent: 04 May 2001 18:34
To: [EMAIL PROTECTED]
Subject: Re: SQL string


Have you done a commit? If not, and you're checking through a different
session, you won't see the update.

-----Original Message-----
From: Paul Foxton [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 04, 2001 12:43 PM
To: [EMAIL PROTECTED]
Subject: Re: SQL string


thanks John,

yes I tried that too.

I'm thinking I must have an error somewhere else now.

the servlet gets right up to: stmt.executeUpdate(sql);

and throws an exception.

Ho hum, back to the drawing board :)

-----Original Message-----
From: John Johnson [mailto:[EMAIL PROTECTED]]
Sent: 04 May 2001 17:47
To: [EMAIL PROTECTED]
Subject: Re: SQL string


Hi Paul,

Don't you need single quotes surrounding the values which you are
inserting??

for example:    INSERT INTO table (field1,field2) VALUES
('value1','value2')

Cheers,
  -john


Paul Foxton wrote:
>
> hopefully a simple one -
>
> can anyone tell me if theres anything wrong with this SQL string?
>
> INSERT INTO Customers (FirstName, LastName, Email, Phone, CompanyName)
> VALUES (wrtwrt, wrtw, wrtwrt, wrtwert, ertwrt)
>
> (all fields are text)
>
> heres the code that generates it:
>
> String sql = "INSERT INTO Customers (" +
>                          "FirstName, LastName, Email, Phone, CompanyName)
"
> +
>                          "VALUES (" + req.getParameter("fname") + ", " +
>                                     req.getParameter("lname") + ", " +
>                                     req.getParameter("email") + ", " +
>                                     req.getParameter("phone") + ", " +
>                                     req.getParameter("company") + ")";
>
> for some reason the update isn't working, just want to check theres
nothing
> wrong with the sring.
>
> I'm accessing an access db via ODBC, I'm getting a connection to the db
ok.
>
> thanks,
>
> Paul
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

--
John Johnson
Software Engineer
Supply Chain Logic, Inc.
301-210-7400, x217

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to