*/
// conn = DriverManager.getConnection(connurl, props); // MySQL (the database must exist and start seperately)
conn = getConnection();
conn.setAutoCommit(false);
} catch (IllegalAccessException exc) {
throw new IOException(exc.getMessage());
} catch (ClassNotFoundException exc) {
throw new IOException(exc.getMessage());
} catch (InstantiationException exc) {
throw new IOException(exc.getMessage());
} catch (SQLException sqle) {
throw new IOException(sqle.getMessage());
}
try {
// Creating a statement lets us issue commands against the connection.
Statement s = conn.createStatement();
// We create the table.
// s.execute("create cached table JoramDB(name VARCHAR PRIMARY KEY, content VARBINARY(256))");
/*
s.execute("CREATE TABLE JoramDB (name VARCHAR(256), content LONG VARCHAR FOR BIT DATA, PRIMARY KEY(name))");
*/
s.execute("CREATE TABLE JoramDB (name VARCHAR(256), content longblob, primary key(name))"); // MySQL
s.close();
conn.commit();
} catch (SQLException sqle) {
String exceptionString = sqle.toString();
if (exceptionString.indexOf("CREATE command denied") == -1)
{
sqle.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
try {
insertStmt = conn.prepareStatement("INSERT INTO JoramDB VALUES (?, ?)");
updateStmt = conn.prepareStatement("UPDATE JoramDB SET content=? WHERE name=?");
deleteStmt = conn.prepareStatement("DELETE FROM JoramDB WHERE name=?");
} catch (SQLException sqle) {
sqle.printStackTrace();
throw new IOException(sqle.getMessage());
} catch (Exception e) {
e.printStackTrace();
// throw e;
}
}