-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
1 changed file
with
13 additions
and
21 deletions.
There are no files selected for viewing
34 changes: 13 additions & 21 deletions
34
src/main/java/cc/baka9/catseedlogin/bukkit/database/SQLite.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 |
---|---|---|
@@ -1,38 +1,30 @@ | ||
package cc.baka9.catseedlogin.bukkit.database; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class SQLite extends SQL { | ||
private Connection connection; | ||
|
||
public SQLite(JavaPlugin javaPlugin){ | ||
super(javaPlugin); | ||
} | ||
|
||
|
||
@Override | ||
public Connection getConnection() { | ||
try { | ||
if (this.connection != null && !this.connection.isClosed()) { | ||
return this.connection; | ||
} | ||
|
||
if (!plugin.getDataFolder().exists()) { | ||
plugin.getDataFolder().mkdir(); | ||
public Connection getConnection() { | ||
try { | ||
if (connection == null || connection.isClosed()) { | ||
if (!plugin.getDataFolder().exists()) plugin.getDataFolder().mkdir(); | ||
Class.forName("org.sqlite.JDBC"); | ||
connection = DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder().getAbsolutePath() + "/accounts.db"); | ||
} | ||
return connection; | ||
} catch (ClassNotFoundException | SQLException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
|
||
Class.forName("org.sqlite.JDBC"); | ||
this.connection = DriverManager.getConnection("jdbc:sqlite:" + plugin.getDataFolder().getAbsolutePath() + "/accounts.db"); | ||
|
||
return this.connection; | ||
} catch (ClassNotFoundException | SQLException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
} | ||
|
||
} |