如果我有一个创建SQL查询的方法,如下所示:
public List selectTuple() {
boolean status = true;
String query = "SELECT ";
query += getFields() == null ? " * " : " " + getFields() + " ";
query += " FROM " + tables;
if ( getSearchClause() != null ) {
query += " " + getSearchClause();
}
query += ";";
Debug("sql...........caleed selectTuple method,query is : "+ query);
setQuery(query);
if ( getPrepared() ) {//If this is a Prepared query,status = setPreparedStatement();
} else {
status = setNonPreparedStatement();
}
if ( ! status ) {
Log("[CRITICAL] (.........)..........");
}
status = doExecuteQuery();
if ( ! status ) {
Log("[CRITICAL] (.........)..........");
}
return( getResults() );
}//method selectTuple
但是,由于这将用于不同的表,因此字段将具有不同的数据类型(int,string,date等).那么如何迭代这样的ResultSet呢?
另外,我如何创建这样的插入查询?
谢谢.