Discussion Locked
0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
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.
4 replies
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.
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.
by dancoo
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.
hey,
DDL statements are not required to commit.........they have implicit commit
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending
Discussion Locked
What Makes a Business Website Effective in 2026
2 helpful
10 replies
1 helpful
3 replies
Question
Windows and macOS computers becoming slow or unstable after updates - what should I check first
0 helpful
1 reply
Question Unanswered
Best Way to Make Long WordPress Location Guides Mobile Friendly
0 helpful
0 replies
Discussion
Optimizing WordPress widgets and DOM size
0 helpful
3 replies