@@ -700,7 +700,7 @@ protected void executeAppJoin(SQLConfig config, List<JSONObject> resultList, Map
700700 jc .putWhere (originKey , null , false ); // remove originKey
701701 jc .putWhere (key + "{}" , targetValueList , true ); // add originKey{} }
702702
703- jc .setMain (true ).setPreparedValueList (new ArrayList <>());
703+ jc .setMain (true ).setPreparedValueList (new ArrayList <>());
704704
705705 // 放一块逻辑更清晰,也避免解析 * 等不支持或性能开销
706706 // String q = jc.getQuote();
@@ -752,7 +752,7 @@ protected void executeAppJoin(SQLConfig config, List<JSONObject> resultList, Map
752752 //
753753 // if (noAggrFun) { // 加 row_number 字段会导致 count 等聚合函数统计出错,结果偏大?
754754 String q = jc .getQuote ();
755- sql2 = prepared ? jc .getSQL (true ) : sql ;
755+ sql2 = prepared && jc . isTDengine () == false ? jc .getSQL (true ) : sql ;
756756
757757 String prefix = "SELECT * FROM(" ;
758758 String rnStr = ", row_number() OVER (PARTITION BY " + q + key + q + ((AbstractSQLConfig ) jc ).getOrderString (true ) + ") _row_num_ FROM " ;
@@ -786,7 +786,7 @@ protected void executeAppJoin(SQLConfig config, List<JSONObject> resultList, Map
786786 executedSQLCount ++;
787787 executedSQLStartTime = System .currentTimeMillis ();
788788 }
789- rs = executeQuery (jc , sql2 );
789+ rs = executeQuery (jc , sql2 );
790790 if (isExplain == false ) {
791791 executedSQLDuration += System .currentTimeMillis () - executedSQLStartTime ;
792792 }
@@ -1085,7 +1085,16 @@ public PreparedStatement getStatement(@NotNull SQLConfig config, String sql) thr
10851085 }
10861086 }
10871087 else if (RequestMethod .isGetMethod (config .getMethod (), true )) {
1088- statement = getConnection (config ).prepareStatement (sql , ResultSet .TYPE_SCROLL_SENSITIVE , ResultSet .CONCUR_UPDATABLE );
1088+ //if (config.isPresto() || config.isTrino()) {
1089+ // statement = getConnection(config).prepareStatement(sql); // , ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
1090+ //} else {
1091+ // statement = getConnection(config).prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
1092+ //}
1093+ if (config .isMySQL () || config .isPostgreSQL () || config .isOracle () || config .isSQLServer () || config .isDb2 ()) {
1094+ statement = getConnection (config ).prepareStatement (sql , ResultSet .TYPE_SCROLL_SENSITIVE , ResultSet .CONCUR_UPDATABLE );
1095+ } else {
1096+ statement = getConnection (config ).prepareStatement (sql );
1097+ }
10891098 }
10901099 else {
10911100 statement = getConnection (config ).prepareStatement (sql );
@@ -1227,15 +1236,19 @@ public void close() {
12271236
12281237 @ Override
12291238 public ResultSet executeQuery (@ NotNull SQLConfig config , String sql ) throws Exception {
1230- if (config .isPresto () || config .isTrino () || config .isTDengine ()) {
1231- Connection conn = getConnection (config );
1232- Statement stt = config .isTDengine ()
1233- ? conn .createStatement () // fix Presto: ResultSet: Exception: set type is TYPE_FORWARD_ONLY, Result set concurrency must be CONCUR_READ_ONLY
1234- : conn .createStatement (ResultSet .TYPE_FORWARD_ONLY , ResultSet .CONCUR_READ_ONLY , ResultSet .HOLD_CURSORS_OVER_COMMIT );
1239+ if (config .isPrepared () == false || config .isTDengine () // TDengine JDBC 不支持 PreparedStatement
1240+ || (config .isExplain () && (config .isPresto () || config .isTrino ()))) { // Presto JDBC 0.277 在 EXPLAIN 模式下预编译值不会替代 ? 占位导致报错
1241+
1242+ Connection conn = getConnection (config );
1243+ Statement stt = conn .createStatement ();
1244+ //Statement stt = config.isTDengine()
1245+ // ? conn.createStatement() // fix Presto: ResultSet: Exception: set type is TYPE_FORWARD_ONLY, Result set concurrency must be CONCUR_READ_ONLY
1246+ // : conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
12351247
12361248 return executeQuery (stt , StringUtil .isEmpty (sql ) ? config .getSQL (false ) : sql );
12371249 }
12381250
1251+ // Presto JDBC 0.277 在 EXPLAIN 模式下预编译值不会替代 ? 占位导致报错
12391252 PreparedStatement stt = getStatement (config , sql );
12401253 ResultSet rs = stt .executeQuery (); //PreparedStatement 不用传 SQL
12411254 // if (config.isExplain() && (config.isSQLServer() || config.isOracle())) {
@@ -1252,8 +1265,12 @@ public int executeUpdate(@NotNull SQLConfig config, String sql) throws Exception
12521265 int count ;
12531266 if (config .isTDengine ()) {
12541267 Connection conn = getConnection (config );
1255- stt = conn .createStatement ();
1256- count = stt .executeUpdate (StringUtil .isEmpty (sql ) ? config .getSQL (false ) : sql );
1268+ stt = conn .createStatement ();
1269+ //stt = config.isTDengine()
1270+ // ? conn.createStatement() // fix Presto: ResultSet: Exception: set type is TYPE_FORWARD_ONLY, Result set concurrency must be CONCUR_READ_ONLY
1271+ // : conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
1272+
1273+ count = stt .executeUpdate (StringUtil .isEmpty (sql ) ? config .getSQL (false ) : sql );
12571274 }
12581275 else {
12591276 stt = getStatement (config );
0 commit comments