try (Connection conn = dataSource.getConnection();
PreparedStatement preparedStatement = conn.prepareStatement(sqq)) {
try (ResultSet rs = preparedStatement.executeQuery()) {
while (rs.next()) {
System.out.println(rs.getInt(1));
System.out.println(rs.getInt(2));
}
}
}
代码正常无错误
Sql sql = Sqls.create(sqq);
sql.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
// List<String> list = new LinkedList<String>();
while (rs.next())
System.out.println(rs.getInt(1));
System.out.println(rs.getInt(2));
return null;
}
});
dao.execute(sql);
nutz回调就报错
DEBUG run.NutDaoExecutor - SQLException
java.sql.SQLException: After end of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:851)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2706)
at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225)
at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225)
at com.dangdang.ddframe.rdb.sharding.merger.resultset.delegate.AbstractDelegateResultSet.getInt(AbstractDelegateResultSet.java:113)
at com.tiankong.Test$1.invoke(Test.java:66)
at org.nutz.dao.impl.sql.NutSql.onAfter(NutSql.java:135)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:277)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:973)
at com.tiankong.Test.main(Test.java:70)
Exception in thread "main" org.nutz.dao.DaoException: !Nutz SQL Error: 'SELECT o.* FROM t_order o'
PreparedStatement:
'SELECT o.* FROM t_order o'
CaseMessage=After end of result set
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:973)
at com.tiankong.Test.main(Test.java:70)
Caused by: java.sql.SQLException: After end of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:851)
at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2706)
at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225)
at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225)
at com.dangdang.ddframe.rdb.sharding.merger.resultset.delegate.AbstractDelegateResultSet.getInt(AbstractDelegateResultSet.java:113)
at com.tiankong.Test$1.invoke(Test.java:66)
at org.nutz.dao.impl.sql.NutSql.onAfter(NutSql.java:135)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:277)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:53)
... 13 more