Commit 35e5b5d 1 parent ef237fe commit 35e5b5d Copy full SHA for 35e5b5d
File tree 1 file changed +13
-21
lines changed
src/main/java/cc/baka9/catseedlogin/bukkit/database
1 file changed +13
-21
lines changed Original file line number Diff line number Diff line change 1
1
package cc .baka9 .catseedlogin .bukkit .database ;
2
2
3
- import org .bukkit .plugin .java .JavaPlugin ;
4
-
5
3
import java .sql .Connection ;
6
4
import java .sql .DriverManager ;
7
5
import java .sql .SQLException ;
8
6
7
+ import org .bukkit .plugin .java .JavaPlugin ;
8
+
9
9
public class SQLite extends SQL {
10
10
private Connection connection ;
11
11
12
12
public SQLite (JavaPlugin javaPlugin ){
13
13
super (javaPlugin );
14
14
}
15
15
16
-
17
16
@ Override
18
- public Connection getConnection () {
19
- try {
20
- if (this .connection != null && !this .connection .isClosed ()) {
21
- return this .connection ;
22
- }
23
-
24
- if (!plugin .getDataFolder ().exists ()) {
25
- plugin .getDataFolder ().mkdir ();
17
+ public Connection getConnection () {
18
+ try {
19
+ if (connection == null || connection .isClosed ()) {
20
+ if (!plugin .getDataFolder ().exists ()) plugin .getDataFolder ().mkdir ();
21
+ Class .forName ("org.sqlite.JDBC" );
22
+ connection = DriverManager .getConnection ("jdbc:sqlite:" + plugin .getDataFolder ().getAbsolutePath () + "/accounts.db" );
23
+ }
24
+ return connection ;
25
+ } catch (ClassNotFoundException | SQLException e ) {
26
+ e .printStackTrace ();
27
+ return null ;
26
28
}
27
-
28
- Class .forName ("org.sqlite.JDBC" );
29
- this .connection = DriverManager .getConnection ("jdbc:sqlite:" + plugin .getDataFolder ().getAbsolutePath () + "/accounts.db" );
30
-
31
- return this .connection ;
32
- } catch (ClassNotFoundException | SQLException e ) {
33
- e .printStackTrace ();
34
- return null ;
35
29
}
36
30
}
37
-
38
- }
You can’t perform that action at this time.
0 commit comments