For your insert, replace
statement.executeQuery( query );
with
int rows = statement.executeUpdate( query );
It has nothing to do with result sets. An "update" can consist of INSERT,
UPDATE, DELETE, and will return the number of rows affected by the SQL
statement. The only time you need to worry about result sets is when doing
a SELECT, and then the executeQuery method would be appropriate.
With regards to the UPDATE not affecting the DB, are you closing the
statement, and the connection? Are you in "autocommit" mode?
Hope this helps,
Clayton
----- Original Message -----
From: "Mick Sullivan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: March 11, 2001 5:43 AM
Subject: SIMPLE SQL QUERY.....
> Hi
> Can anyone help me with a simple SQL update query.
> When I insert a value into my DB using the INSERT INTO statement I have no
> problem.
>
> Statement statement = connection.createStatement();
>
> String query = "INSERT INTO parkingPrice (" +
> " price " +
> ") VALUES ('" +
> thePrice +
> "')";
> statement.executeQuery( query );
>
> However I dont want multiple rows so when I try and do an update instead
> using the following:
>
> String query = "UPDATE parkingPrice SET " +
> "Price='" + thePrice + "'";
>
> System.out.println("query "+ query);
> statement.executeUpdate( query );
>
> There is no affect on the DB. I get no SQL errors and in the tomcat window
> using the line "System.out.println("query "+ query);"
> The query UPDATE parkingPrice SET Price='5'
> The query seems valid yet there is no affect on the DB.
> I am using MS ACCESS. Is the problem in the way the DB is set up?
> Thanks in advance, Mick
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]