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
_EsamAsked:
Who is Participating?
 
mukundha_expertConnect With a Mentor Commented:
try this,

its working in sqlserver,

"update table_name set col_name = colname+1 where col_key = value"
0
 
mukundha_expertCommented:
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() ;
0
 
_EsamAuthor Commented:
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
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
mukundha_expertCommented:
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
0
 
CEHJCommented:
Use an updatable ResultSet
0
 
_EsamAuthor Commented:
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
0
 
_EsamAuthor Commented:
>Use an updatable ResultSet

How ?
Please show me for clarity!

Thanks.
_Esam
0
 
CEHJCommented:
You already know - you did it before ;-)
0
 
_EsamAuthor Commented:
Didn't work for me ! :)
Let us make it work !

_Esam
0
 
mukundha_expertCommented:
wat is the datatype of that column??
0
 
_EsamAuthor Commented:
Sorry mukundha...
It finally worked ..   can't be sure what the problem was..

Luckily the datatype is a number..

Thanks..
_Esam
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.