Trying to use sql statement batchs to do the following: every 5 minutes, add a statement to batch (current counter) then every hour send, send the statements to the database.
I'm curious though, do I need to reinitialize the statement/connection whenever I add to it or send the batch?
here's how i think i would go about doing this, just need some clarification on how to do it smarter or if this is the best way
on program startup, initialize the following
Connection connection = null;
Statement statement = null;
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/youtube", "root", "root");
statement = connection.createStatement();
then every 5 minutes.... addToBatch(connection, statement, counter, time, date);
then hour... statement.executeBatch();
am i missing anything? do i need to remake the connection?
any information is helpful, thank you!