18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 import java.sql.Connection;
22 import java.sql.DriverManager;
23 import java.sql.ResultSet;
24 import java.sql.SQLException;
25 import java.sql.Statement;
26 import java.util.Random;
29 final static Logger
MAPDLOGGER = LoggerFactory.getLogger(Worker.class);
31 static final String
JDBC_DRIVER =
"com.omnisci.jdbc.OmniSciDriver";
32 static final String
DB_URL =
"jdbc:omnisci:localhost:6274:omnisci";
35 static final String
USER =
"admin";
36 static final String
PASS =
"HyperInteractive";
38 private Connection
conn = null;
39 private Statement
stmt = null;
41 Random
r =
new Random();
55 MAPDLOGGER.info(
threadId +
": Connecting to database...");
57 stmt = conn.createStatement();
61 doQuery(conn,
"create table if not exists t" + i +
" (newn int)", stmt);
63 }
catch (SQLException se) {
67 }
catch (ClassNotFoundException ex) {
74 int tab = this.threadId;
75 for (
int i = 0; i < 100; i++) {
85 }
catch (SQLException se) {
88 }
catch (Exception e) {
97 }
catch (SQLException se2) {
103 }
catch (SQLException se) {
104 se.printStackTrace();
109 private void doQuery(Connection
conn, String sql, Statement
stmt)
throws SQLException {
112 rs = stmt.executeQuery(sql);
113 }
catch (SQLException se) {
114 if (se.getMessage().contains(
"does not exist")) {
115 MAPDLOGGER.info(
threadId +
": table not present");
122 int sum = rs.getInt(1);
124 MAPDLOGGER.info(
threadId +
": result " + sum);
130 throws SQLException {
135 throws SQLException {
void doQuery(Connection conn, String sql, Statement stmt)
static final Logger MAPDLOGGER
static final String JDBC_DRIVER
void doSelectQuery(Connection conn, Statement stmt, int tab)
void doInsertQuery(Connection conn, Statement stmt, int tab)
static final String DB_URL