Hi Clayton,
Thanks for the help, but there is still a new row added into the table 
"parkingPrice". This is what my applyChanges methos looks like now
public void applyChanges() throws Exception
{
     Statement statement = connection.createStatement();

     String query = "INSERT INTO parkingPrice (" +
                    " price " +
                    ") VALUES ('" +
                    thePrice +
                    "')";

     //String query = "UPDATE parkingPrice  SET " +
     //"Price= thePrice ;

     System.out.println("query "+ query);
     //statement.executeUpdate( query );
     //statement.executeQuery( query );
     int rows = statement.executeUpdate( query );
     }
}

The variable thePrice is taken from a jsp page and the function just takes 
the value "price" and assigns it to thePrice;
public void setPrice( String price ) {
        thePrice = price;
    }

Any ideas,
Thanks in advance, Mick

----Original Message Follows----
From: "Clayton Peirens" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: <[EMAIL PROTECTED]>
Subject: Re: SIMPLE SQL QUERY.....
Date: Sun, 11 Mar 2001 08:14:27 -0700

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]


_________________________________________________________________________
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]

Reply via email to