This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes increment a number in a column? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "increment a number in a column?" Watch "increment a number in a column?" New topic
Author

increment a number in a column?

davy nolan
Greenhorn

Joined: Mar 20, 2001
Posts: 6
Hello,
Just wondering what would be the best way to increment a number in a column in a database.The situation is that the database must record the number of hits a user makes to the site. So I must retrieve the number for the particular row for that user and increment it each time they logon to the site. Is there any one liner way of doing this? I am using the Oracle 9i database and the userid is the primary key for each row.

Cheers,
Davy Nolan
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
UPDATE user_hits SET hits = hits + 1 WHERE user_id = ?
Use a PreparedStatement for this so the database can cache it.
- Peter
 
Have you checked out Aspose?
 
subject: increment a number in a column?
 
It's not a secret anymore!