summaryrefslogtreecommitdiff
path: root/src/main/java/io/trygvis/jz14/demo/InserterMain.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/trygvis/jz14/demo/InserterMain.java')
-rw-r--r--src/main/java/io/trygvis/jz14/demo/InserterMain.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main/java/io/trygvis/jz14/demo/InserterMain.java b/src/main/java/io/trygvis/jz14/demo/InserterMain.java
new file mode 100644
index 0000000..1192a09
--- /dev/null
+++ b/src/main/java/io/trygvis/jz14/demo/InserterMain.java
@@ -0,0 +1,37 @@
+package io.trygvis.jz14.demo;
+
+import org.slf4j.Logger;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.util.Random;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+public class InserterMain {
+ Logger log = getLogger(getClass());
+ Db db = new Db("inserter");
+ Random r = new Random();
+
+ public static void main(String[] args) throws Exception {
+ new InserterMain().main();
+ }
+
+ public void main() throws Exception {
+ Connection c = db.getConnection();
+ c.setAutoCommit(false);
+
+ PreparedStatement stmt = c.prepareStatement("INSERT INTO mail_raw_t(raw) VALUES(?)");
+ int count = 1 + r.nextInt(9);
+
+ for (int i = 0; i < count; i++) {
+ stmt.setString(1, "mail #" + i);
+ stmt.execute();
+ }
+ c.commit();
+
+ log.info("INSERT performed, count={}", count);
+
+ c.close();
+ }
+}