Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Update a record through JDBC

Posted on 2006-06-20
11
Medium Priority
?
220 Views
Last Modified: 2010-08-05
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
0
Comment
Question by:_Esam
  • 5
  • 4
  • 2
11 Comments
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 16943940
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
 

Author Comment

by:_Esam
ID: 16944070
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
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 16944339
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 86

Expert Comment

by:CEHJ
ID: 16944416
Use an updatable ResultSet
0
 

Author Comment

by:_Esam
ID: 16944448
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
 

Author Comment

by:_Esam
ID: 16944472
>Use an updatable ResultSet

How ?
Please show me for clarity!

Thanks.
_Esam
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16944487
You already know - you did it before ;-)
0
 
LVL 10

Accepted Solution

by:
mukundha_expert earned 200 total points
ID: 16944510
try this,

its working in sqlserver,

"update table_name set col_name = colname+1 where col_key = value"
0
 

Author Comment

by:_Esam
ID: 16944518
Didn't work for me ! :)
Let us make it work !

_Esam
0
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 16944542
wat is the datatype of that column??
0
 

Author Comment

by:_Esam
ID: 16944801
Sorry mukundha...
It finally worked ..   can't be sure what the problem was..

Luckily the datatype is a number..

Thanks..
_Esam
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question