简体   繁体   中英

can I use batch for execute queries in jdbc?

I have two queries that have to execute

q1: insert into TABLE_A(A,B,C,D) values(?,?,?,?)

q2: insert into TABLE_B(E,F,G,H,I) values(?,?,?,?,?)

Can't I use a batch to use one PreparedStatement?

It's the only way to create stored procedure?

No, you cannot. A PreparedStatement concerns a single statement. You cannot use it to batch two different statements.

However, depending on the database, you might be able to treat multiple statements as a single statement (eg using anonymous code blocks or similar solutions). In those databases you can then prepare that block and batch sets of parameters for that block.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM