General discussion

  • Creator
    Topic
  • #2179198

    JDBC:does nt let me create 2 tables!

    Locked

    by rohan_technews ·

    I have made an awt interface.in that i have 2 buttons to create their respective tables in database.the problem is that when i create table B immediately after i create table a i get an sql exception.tab b has a foreign key of tab a(id). i need to close my interface and then create table b. then it gets created.

All Comments

  • Author
    Replies
    • #3137354

      Reply To: JDBC:does nt let me create 2 tables!

      by saurabhambekar ·

      In reply to JDBC:does nt let me create 2 tables!

      It is clear that, when u try to create table B (which has a foreign key for table A), the metadata of table A is not yet available.

      i dont know the exact solution to this problem, but let few seconds pass and then create table B. i know this sounds stupid, but give it a try.

      Or

      close and reopen the connection before creating table B and then check the result.

    • #3118407

      Reply To: JDBC:does nt let me create 2 tables!

      by martin simons ·

      In reply to JDBC:does nt let me create 2 tables!

      The first thing to look at, wuld be make sure that the table creation from button a is actually committed. do you have a console to the database so that you can look and see that the table exists after pushing button a, but before closing the application. It seems to me that problem lies in the commit. The sql executed from the first command will not be available to other db sessions until after a commit has been run.

    • #3118278

      Reply To: JDBC:does nt let me create 2 tables!

      by dancoo ·

      In reply to JDBC:does nt let me create 2 tables!

      Martin is right. Your code has to explicitly commit the first table creation before you can do the 2nd one. You can’t do them together in one batch of SQL.

    • #3117992

      Reply To: JDBC:does nt let me create 2 tables!

      by saurabhambekar ·

      In reply to JDBC:does nt let me create 2 tables!

      hey,

      DDL statements are not required to commit………they have implicit commit

Viewing 3 reply threads