I fetched a data from a database table. It is an integer value. Now I want to increase it by 1 and send it to another table. Can this be done to increase its value by 1?
String transaction = resultset.getString(1) + 1;
I fetched a data from a database table. It is an integer value. Now I want to increase it by 1 and send it to another table. Can this be done to increase its value by 1?
String transaction = resultset.getString(1) + 1;
I would actually recommend just doing a single insert or update operation. For example, if you wanted to insert this value into a new record in another table you could try:
INSERT INTO other_table (col)
SELECT id + 1
FROM first_table;
This would only require a single trip to the database, rather than making two trips, via a separate select and DML statements.
This answer is a bit thin on Java code, but for boilerplate JDBC code, you should refer to Java Trails or another SO question.