General discussion

Locked

JDBC:does nt let me create 2 tables!

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.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by saurabhambekar In reply to JDBC:does nt let me creat ...

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.

Collapse -

by Martin Simons In reply to JDBC:does nt let me creat ...

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.

Collapse -

by dancoo In reply to JDBC:does nt let me creat ...

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.

Collapse -

by saurabhambekar In reply to JDBC:does nt let me creat ...

hey,

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

Back to Web Development Forum
4 total posts (Page 1 of 1)  

Related Forums