Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jdbc restart transaction on deadlock

807580Feb 4 2010 — edited Feb 4 2010
All,

I'd like to keep attempting my jdbc work if there is a deadlock or any exception.
Here is my code:
boolean working = true;
while(working){
		try {
			Class.forName(driver);
			Connection conn = DriverManager.getConnection(url, user, password);
			
			Statement st = conn.createStatement();
			x = st.executeUpdate(query);
			
			st.close();
			conn.close();
		}catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
			working = false;
		}
		return x;
Is this a good or bad way of restarting my jdbc work?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 4 2010
Added on Feb 4 2010
7 comments
346 views