News Stay informed about the latest enterprise technology news and product updates.

Key tips when using JDBC to update databases

Key tips

Key tips

Commitment control
Remember, in practice, you really want full commitment control on your database transactions. You won't select the option I did to set the transaction isolation level for the JDBC connection to none. See java.sql.Connection class for more on the specific JDBC transaction isolation levels. You can choose the data access concurrency control policy you want using the available choices in the Connection class.

You can use auto commit in some cases to easily allow the JDBC driver to manage committing the changes you make to the database after every single statement. As in my example here, in many cases, you'll want to commit or rollback changes to the database as a unit. In those cases, you'll set the commitment control to program (connection.setAutoCommit(false)).
In the real world, to run my example on an iSeries, the user profile running the example would have to have full authority to read, write and create objects in the specified data library.
JDBC operation
JDBC runs in background threads in SQL server mode. The Java toolbox jobs for JDBC can be identified in SYSWRK subsystem by the job name of QZDASOINIT. In addition to looking at local error messages in the client job running the JDBC commands, you can also look in these server jobs for more detailed messages based on the logging level setup for these jobs in the job description.

Dig Deeper on iSeries skills

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.