Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update a record through JDBC

Posted on 2006-06-20
11
Medium Priority
?
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

704 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