db and internal's implementation

This commit is contained in:
ChessNineeee committed 2021-04-02 20:41:37 +08:00
1 parent 402267fa57
commit cf6717b169
3 files changed
+172 -7

No files matched your search

@@ -64,12 +64,13 @@ public class Sqlite {
Statement stmt = null;
try{
String homePath = SqliteUtil.home();
homePath += "/min/identity";
homePath += "/min/identity/";
String dbPath = homePath;
if (!SqliteUtil.pathExists(dbPath)){
new File(dbPath).mkdirs();
}
String real_db_file = dbPath + db_file;
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:" + real_db_file);
stmt = c.createStatement();
stmt.executeUpdate(table_create);
@@ -91,6 +92,7 @@ public class Sqlite {
new File(filePath).mkdirs();
}
String real_db_file = filePath + db_file;
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:" + real_db_file);
stmt = c.createStatement();
stmt.executeUpdate(table_create);
@@ -104,10 +106,11 @@ public class Sqlite {
}
}
public Connection getConn() throws SQLException {
public Connection getConn() throws Exception {
Connection c = null;
try{
String real_db_file = db_path + db_file;
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:" + real_db_file);
// TODO 设置数据库最大连接数
return c;