I am working with mysql in Java.
Basically, I have multiple queries that each create a table in the database, along with a single ALTER statement that adjusts the auto-increment initial value for one of my attributes. I am executing those queries as a transaction--namely either all are committed to the database or none are. But to do so I have create a separate Statement for each query - 8 in total - and execute each. After, I commit all the results. And then I have to close each Statement.
But this seems inefficient. To many Statements. So I wonder whether batch methods would work. My concern is that batch methods execute all the queries simultaneously, and since I have Referential Integrity Constraints and the ALTER query there is a dependancy between the tables - and thus the order in which they are created matters. Is this not correct ? Am I misunderstanding how batch statements work ?
If my logic above is correct, then should I possibly group a few queries together (that are not related) and use batch methods to execute them. This will then reduce the number of Statements I have.