Catch table not exsist in java
===

I need to insert some data to a table. When program executes to insert there may arise an error bcoz i havn't created the table. I would like to create that table in catch block and return to try block. So when ever the table is deleted or happens to delete the try catch will build the table.

I have wrote some code for it. but it fails. Thanks for your attentions.


    import java.sql.*;
    
    /**
     *
     * @author JOJO
     */
    public class ConnectDB {
      static Connection conn;
       static String driver = "org.apache.derby.jdbc.ClientDriver";
       static String connectionURL = "jdbc:derby://localhost:1527/Libraryprj;user=scott;password=tiger";
    
      public void AddBookDB(String bookName) throws SQLException {
    
        String createString = "CREATE TABLE BOOKLEDGER (BOOKNAME VARCHAR(50) NOT NULL)";
        try {
          Class.forName(driver);
        } catch (java.lang.ClassNotFoundException e) {
          e.printStackTrace();
        }
        try
            {
                conn = DriverManager.getConnection(connectionURL);
                Statement stmt = conn.createStatement();
                boolean execute = stmt.execute("insert into BOOKLEDGER values ('" + bookName + "')");
                stmt.close();
            }
            catch (SQLException sqlExcept)
            {
                Statement stmt = (Statement) conn.createStatement();
                stmt.executeUpdate(createString);
                
                sqlExcept.printStackTrace();
            }
      }
    }