@@ -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