• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to tell if a DDL has failed?  RSS feed

 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very new to JDBC.

If i issue a DDL, say "alter table", by stmt.execute() or
stmt.executeUpdate(), is there any way I can check if the statement is
successfully executed in the db? The return value of stmt.executeUpdate() is int and is 0 for DDL. So, is there any way to differentiate between a successful DDL vs a failed one?
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should throw a SQLException. You could try it out with simple DDL that will obviously fail.

See Statement API

executeUpdate
public int executeUpdate(String sql)
throws SQLException
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!