赞
踩
代码如下:Stringsqlstr="select*from"+FormKey+"whereregist_id='"+registId+"'";Connectionconn=null;Statementst=null;ResultSetrs=null;Listresult=newArrayList...
代码如下:
String sqlstr = "select * from " + FormKey + " where regist_id = '" + registId +"'";
Connection conn = null;
Statement st = null;
ResultSet rs = null;
List result = new ArrayList();
try {
DataSource dataSource = (DataSource) AppUtil.getBean("hyDataSource");
conn = dataSource.getConnection();
st = conn.createStatement();
rs = st.executeQuery(sqlstr);
while (rs.next()) {
rs.getLong(0);
//rs.getString(1);
//rs.getString(2);
//rs.getString(3);
//for(int i=0;i
//int a= rs.getFetchSize();
//}
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
以上sql文执行出来的结果集,在java中需要怎么处理?
如果这种方法不可以的话,还有其他什么办法么?struts2+hibernate+spring框架下还有其他什么办法可以实现表名作为动态参数,执行出来的结果接该怎么接?
展开
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。