public Date getLAST_DDL_TIME() {
return LAST_DDL_TIME;
}
public void setLAST_DDL_TIME(Date last_ddl_time) {
LAST_DDL_TIME = last_ddl_time;
}
public String getTIMESTAMP() {
return TIMESTAMP;
}
public void setTIMESTAMP(String timestamp) {
TIMESTAMP = timestamp;
}
public String getSTATUS() {
return STATUS;
}
public void setSTATUS(String status) {
STATUS = status;
}
public String getTEMPORARY() {
return TEMPORARY;
}
public void setTEMPORARY(String temporary) {
TEMPORARY = temporary;
}
public String getGENERATED() {
return GENERATED;
}
public void setGENERATED(String generated) {
GENERATED = generated;
}
public String getSECONDARY() {
return SECONDARY;
}
public void setSECONDARY(String secondary) {
SECONDARY = secondary;
}
public String toString()
{
StringBuffer ret = new StringBuffer();
ret.append("[OWNER=").append(OWNER).append("]")
.append("[OBJECT_NAME=").append(OBJECT_NAME).append("]")
.append("[SUBOBJECT_NAME=").append(SUBOBJECT_NAME).append("]")
.append("[OBJECT_ID=").append(OBJECT_ID).append("]")
.append("[DATA_OBJECT_ID=").append(DATA_OBJECT_ID).append("]")
.append("[OBJECT_TYPE=").append(OBJECT_TYPE).append("]")
.append("[CREATED=").append(CREATED).append("]")
.append("[LAST_DDL_TIME=").append(LAST_DDL_TIME).append("]")
.append("[TIMESTAMP=").append(TIMESTAMP).append("]")
.append("[STATUS=").append(STATUS).append("]")
.append("[TEMPORARY=").append(TEMPORARY).append("]")
.append("[GENERATED=").append(GENERATED).append("]")
.append("[SECONDARY=").append(SECONDARY).append("]");
return ret.toString();
}
}
首先看一下默认的查询方法:
import com.frameworkset.common.poolman.PreparedDBUtil;
import com.frameworkset.common.poolman.handle.RowHandler;
。。。。
PreparedDBUtil dbUtil = new PreparedDBUtil();
try {
dbUtil.preparedSelect("select owner from testnewface where object_id < ?");
dbUtil.setInt(1, 100);
List list = dbUtil.executePreparedForList(TestNewface.class);//已经将查询结果转化为TestNewface类型的对象列表
for(int i = 0; i < list.size(); i ++)
{
TestNewface testNewface = (TestNewface)list.get(i);
System.out.println(testNewface);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
再看一下行处理器的使用方法,由应用程序来将记录Record中的列的值放入对象的属性中:
import com.frameworkset.common.poolman.PreparedDBUtil;
import com.frameworkset.common.poolman.Record;
import com.frameworkset.common.poolman.handle.RowHandler;
。。。。
PreparedDBUtil dbUtil = new PreparedDBUtil();
try {
dbUtil.preparedSelect("select * from testnewface where object_id < ?");
dbUtil.setInt(1, 100);
List list = dbUtil.executePreparedForList(TestNewface.class,new RowHandler()//定义行处理器
{
public void handleRow(Object rowValue, Record record) {//实现行处理器接口方法,rowValue参数就是要设置的空的对象实例,record就是包含了查询列表中当前记录的所有列和值信息。
TestNewface t = (TestNewface)rowValue;//转化为TestNewface对象,记住这时的属性值都是初始值
try {
t.setCREATED(record.getDate("created"));
t.setDATA_OBJECT_ID(record.getInt("DATA_OBJECT_ID"));
//........设置其他的属性
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("row handler:"+t);
}
});
for(int i = 0; i < list.size(); i ++)
{
TestNewface testNewface = (TestNewface)list.get(i);
System.out.println(testNewface);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
上一页 [1] [2]
责任编辑:小草