aspose file tools*
The moose likes JDBC 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

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "increment a number in a column?" Watch "increment a number in a column?" New topic

increment a number in a column?

davy nolan

Joined: Mar 20, 2001
Posts: 6
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.

Davy Nolan
Peter den Haan
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
I agree. Here's the link:
subject: increment a number in a column?
Similar Threads
Size of the arraylist different after deleting the record?
GUI question
Record Locking in multi-user
Regarding Jtable row Deletion
making a JTable column not visible