Link to home
Start Free TrialLog in
Avatar of _Esam
_Esam

asked on

Update a record through JDBC

Hi,
I need to know how to update a record with jdbc with a previous value in the table column!

I want to update a record and set a count column like count+1 for certain condition?
How I do that?


_Esam
Avatar of mukundha_expert
mukundha_expert

send a query
create a statement or prepared statement with the query,

               "update table_name set col_name = value where col_key = value"

and call executeUpdate() ;
Avatar of _Esam

ASKER

You missed my point, I think...

>"update table_name set col_name = value where col_key = value"  - I know this..

I wanted to know .. how could I do it.. if I wanted to increment the value by 1 ???


_Esam
select that column, increment it and update the new value to the database,


else write a stored procedure in DB and call that from ur java class
Avatar of CEHJ
Use an updatable ResultSet
Avatar of _Esam

ASKER

I couldn't update the Timestamp with the Updatable ResultSet ???

Can't believe circling in the same loop :)

No Stored Procedure for me!! Forbidden for me !! :)

Thanks.
_Esam
Avatar of _Esam

ASKER

>Use an updatable ResultSet

How ?
Please show me for clarity!

Thanks.
_Esam
You already know - you did it before ;-)
ASKER CERTIFIED SOLUTION
Avatar of mukundha_expert
mukundha_expert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of _Esam

ASKER

Didn't work for me ! :)
Let us make it work !

_Esam
wat is the datatype of that column??
Avatar of _Esam

ASKER

Sorry mukundha...
It finally worked ..   can't be sure what the problem was..

Luckily the datatype is a number..

Thanks..
_Esam