public List<Map<String,String>> queryMapValues(Dao dao, String table, Condition cnd) {
Sql sql= Sqls.create("select * from $table");
if (cnd!=null){
sql= Sqls.create("select * from $table"+cnd.toString());
}
sql.vars().set("table",table);
sql.setCallback(new SqlCallback() {
List<Map<String,String>> list=new LinkedList<>();
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
Map<String,String> map = new LinkedHashMap<>();
while (rs.next()) {
String name=rs.getCursorName();
map.put(name, rs.getString(name));
}
list.add(map);
return list;
}
});
dao.execute(sql);
List<Map<String,String>> list=(List<Map<String,String>>)sql.getResult();
System.gc();
return list;
}
执行上述函数,在rs.getCursorName()时报错,如下:
Caused by: java.sql.SQLException: Positioned Update not supported.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.ResultSetImpl.getCursorName(ResultSetImpl.java:1966)
at com.alibaba.druid.filter.FilterChainImpl.resultSet_getCursorName(FilterChainImpl.java:962)
at com.alibaba.druid.filter.FilterAdapter.resultSet_getCursorName(FilterAdapter.java:1553)
at com.alibaba.druid.filter.FilterChainImpl.resultSet_getCursorName(FilterChainImpl.java:960)
at com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl.getCursorName(ResultSetProxyImpl.java:389)
at com.alibaba.druid.pool.DruidPooledResultSet.getCursorName(DruidPooledResultSet.java:421)
at cn.wizzer.app.stargis.util.QueryEx$4.invoke(QueryEx.java:152)
at org.nutz.dao.impl.sql.NutSql.onAfter(NutSql.java:136)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:277)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
... 77 more