-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88101f5
commit 2fae20c
Showing
9 changed files
with
110 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/cjburkey/claimchunk/data/SqlDataStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/cjburkey/claimchunk/database/DatabaseConnect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.cjburkey.claimchunk.database; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
import com.cjburkey.claimchunk.Utils; | ||
|
||
public class DatabaseConnect { | ||
|
||
private final String hostName; | ||
private final String database; | ||
private final String username; | ||
private final String password; | ||
private final int port; | ||
private Connection connection; | ||
|
||
public DatabaseConnect(String hostName, String database, String user, String pass, int port) { | ||
this.hostName = hostName; | ||
this.database = database; | ||
username = user; | ||
password = pass; | ||
this.port = port; | ||
} | ||
|
||
public boolean openConnection() throws SQLException { | ||
synchronized (this) { | ||
if (connection != null && !connection.isClosed()) { | ||
return false; | ||
} | ||
try { | ||
Class.forName("com.mysql.jdbc.Driver"); | ||
} catch (ClassNotFoundException e) { | ||
Utils.log("JDBC not found."); | ||
return false; | ||
} | ||
StringBuilder connect = new StringBuilder(); | ||
connect.append("jdbc:mysql://"); | ||
connect.append(hostName); | ||
connect.append(':'); | ||
connect.append(port); | ||
connect.append('/'); | ||
connect.append(database); | ||
connection = DriverManager.getConnection(connect.toString(), username, password); | ||
return true; | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters