· 6 years ago · Jul 02, 2019, 09:56 PM
1connection = DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database, this.user, this.password);
2
3public MySql initialize() {
4
5 connect();
6
7 try {
8 connection.prepareStatement("SELECT 1 FROM guilds LIMIT 1").executeQuery();
9 } catch (SQLException e) {
10 try {
11 connection.prepareStatement(
12 "CREATE TABLE IF NOT EXISTS `guilds` (n" +
13 " `id` text,n" +
14 " `prefix` text,n" +
15 " `joinmsg` text,n" +
16 " `leavemsg` text,n" +
17 ") ENGINE=InnoDB DEFAULT CHARSET=utf8;"
18
19 ).execute();
20
21 connection.prepareStatement(
22 "CREATE TABLE IF NOT EXISTS `autochans` (n" +
23 " `chan` text,n" +
24 " `guild` text,n" +
25 ") ENGINE=InnoDB DEFAULT CHARSET=utf8;"
26 ).execute();
27
28 System.out.println("MySql structure created...");
29 } catch (SQLException e1) {
30 e1.printStackTrace();
31 }
32 }
33
34 return this;
35 }