[英]How return row_number use prepared Statement with StringBuffer in Java
I want the return row_number press the Variable Model class: 我想返回row_number按变量模型类:
Whereas the PreparedStatament in the examples I exploreri, rferencia the column name. 在我探索的示例中,PreparedStatament是列名。 row_number is not a native or physical column of the table.
row_number不是表的本机列或物理列。 How to make the values dete method are returned as if they were an actual physical table column.
将返回如何使值dete方法变为实际物理表列的方式。 Nor would it be interesting to create a new column in the table to just store these values.
在表中创建一个新列以仅存储这些值也不会很有趣。 I also do not intend to use triggers to return these values.
我也不打算使用触发器返回这些值。 It can be done this way is without error in the code below.
可以通过这种方式完成,而在下面的代码中没有错误。
final StringBuffer lSql = new StringBuffer();
lSql.append("SELECT ");
lSql.append(" TABLE_NAME.ROW_NUMBER() OVER (ORDER BY COLUMN_DAY) ");
lSql.append("FROM ...");
// ...
final List<classModel> listData = new ArrayList<classModel>();
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rset = null;
try{
conn = getConnection1();
stmt = conn.prepareStatement(lSql.toString());
int count = 1;
//stmt.setLong(count++, classModelParameterThisFunctionDAO.getVarColumnSequence());
//...
rset = stmt.executeQuery(); // ERROR THIS LINE NI DEBUG
while(rset.nex()){
final classModel lClassModel = new classModel();
lClassModel.setColumnSequence(rset.getInt("ROW_NUMBER() OVER (ORDER BY COLUMN_DAY)")); //error in this line
listData.add(lClassModel);
lSql.append("SELECT ");
lSql.append(" TABLE_NAME.ROW_NUMBER() OVER (ORDER BY COLUMN_DAY) as RRN ");
lSql.append("FROM ...")
.
.
.
lClassModel.setColumnSequence(rset.getInt("RRN"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.