(1)建表语句
sqlMap:
<statement id="createTable" parameterClass="String" >
$sql$
</statement>
java:
StringBuffer sb = new StringBuffer();
String tableName = "BACKUP_"+sdf.format(new Date()) +"_USER";
sb.append("CREATE TABLE " + tableName);
System.out.println();
sb.append(" AS");
System.out.println();
sb.append(" SELECT name, id,sex FROM ATEST");
System.out.println();
String sql = sb.toString();
System.out.println(sql);
System.out.println();
sqlMap.update("createTable", sql);
(2)关键字like使用
( NAME LIKE '%' || #name:VARCHAR# || '%')
(3)批量导入
public class PublicDAOImpl extends BaseSqlMapDaoSupport
implements IPublicDAO
{
public Object insert(String tableName, Object objParam)
{
return getSqlMapClientTemplate()
.insert(tableName + "_insert", objParam);
} public boolean batchInsert(final String tableName, final List<QosUserBean> users) { getSqlMapClientTemplate().execute(new SqlMapClientCallback() { public Object doInSqlMapClient(SqlMapExecutor executor)throws SQLException {
executor.startBatch(); for (int i = 0;i < users.size(); i++) {
executor.insert(tableName + "_insert", users.get(i));
}
executor.executeBatch();
return true;
}
});
return true;
}
}
(4)