Skip to content

Commit bc135fb

Browse files
committed
dbUri 完全交给用户控制,不再针对 MySQL 版本号来自动配置参数;升级版本号为 4.3.0
1 parent a502f95 commit bc135fb

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

APIJSONORM/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>apijson.orm</groupId>
77
<artifactId>apijson-orm</artifactId>
8-
<version>4.2.4</version>
8+
<version>4.3.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>APIJSONORM</name>

APIJSONORM/src/main/java/apijson/orm/AbstractSQLExecutor.java

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -666,31 +666,8 @@ public Connection getConnection(@NotNull SQLConfig config) throws Exception {
666666
connection = connectionMap.get(config.getDatabase());
667667
if (connection == null || connection.isClosed()) {
668668
Log.i(TAG, "select connection " + (connection == null ? " = null" : ("isClosed = " + connection.isClosed()))) ;
669-
670-
if (config.isMySQL()) {
671-
int v;
672-
try {
673-
String[] vs = config.getDBVersion().split("[.]");
674-
v = Integer.parseInt(vs[0]);
675-
}
676-
catch (Exception e) {
677-
v = 1;
678-
Log.e(TAG, "getStatement try { String[] vs = config.getDBVersion().split([.]); ... >> } catch (Exception e) {\n" + e.getMessage());
679-
}
680-
681-
if (v >= 8) {
682-
connection = DriverManager.getConnection(config.getDBUri() + "?userSSL=false&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&user="
683-
+ config.getDBAccount() + "&password=" + config.getDBPassword());
684-
}
685-
else {
686-
connection = DriverManager.getConnection(config.getDBUri() + "?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&user="
687-
+ config.getDBAccount() + "&password=" + config.getDBPassword());
688-
}
689-
}
690-
else { //PostgreSQL 不允许 cross-database
691-
connection = DriverManager.getConnection(config.getDBUri(), config.getDBAccount(), config.getDBPassword());
692-
}
693-
669+
// PostgreSQL 不允许 cross-database
670+
connection = DriverManager.getConnection(config.getDBUri(), config.getDBAccount(), config.getDBPassword());
694671
connectionMap.put(config.getDatabase(), connection);
695672
}
696673

@@ -795,14 +772,14 @@ public ResultSet executeQuery(@NotNull SQLConfig config) throws Exception {
795772
public int executeUpdate(@NotNull SQLConfig config) throws Exception {
796773
PreparedStatement s = getStatement(config);
797774
int count = s.executeUpdate(); //PreparedStatement 不用传 SQL
798-
775+
799776
if (config.getMethod() == RequestMethod.POST && config.getId() == null) { //自增id
800777
ResultSet rs = s.getGeneratedKeys();
801778
if (rs != null && rs.next()) {
802779
config.setId(rs.getLong(1));//返回插入的主键id
803780
}
804781
}
805-
782+
806783
return count;
807784
}
808785

0 commit comments

Comments
 (0)