Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void setupTables() throws SQLException {
- // Let's actually use the database they're asking us to use, mmkay?
- PreparedStatement createDb = connection.prepareStatement("CREATE DATABASE ? IF NOT EXISTS");
- PreparedStatement useDb = connection.prepareStatement("USE ?");
- createDb.setString(0, database);
- useDb.setString(0, database);
- createDb.execute();
- useDb.execute();
- createDb.close();
- useDb.close();
- connection.createStatement().execute("CREATE TABLE players IF NOT EXISTS {" +
- "name varchar(200) NOT NULL," +
- "money double NOT NULL," +
- "}");
- connection.createStatement().execute("CREATE TABLE banks IF NOT EXISTS {" +
- "bankname varchar(200) NOT NULL," +
- "owner varchar(200)," +
- "FOREIGN KEY (owner) REFERENCES players(name)," +
- "}");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement