Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SQL queries  RSS feed

 
natasa jones
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all!
i am new in sql and i would like to insert user's data in two different tables. can i use a single query to do that and how ?or should i have 2 preparedStatements in one class for each insert query?
any help appreciated!
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use executeBatch() or you can turn autocommit off before executing sstatements and them execute both of your statement and after you execute both sql statement , you can commint the chanes.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!