/** * 采用Null行处理器的通用查询,适用于单个Object查询,List查询等等 * @param rowhandler * @param sql * @param fields * @throws SQLException */ public static void queryByNullRowHandler(NullRowHandler rowhandler, String sql, Object... fields) throws SQLException { queryWithDBNameByNullRowHandler( rowhandler,null, sql, fields); }
public static DBJob getDBJob(String jobname) throws Exception { return SQLExecutor.queryObject(DBJob.class, "select * from jobconfig where jobname=?", jobname); } public static void initConfgDB(String dbpath)
public static void addOrUdate(String jobname,String jobdef) throws Exception { int count = SQLExecutor.queryObjectWithDBName(int.class,"bigdata_conf", "select count(1) from jobconfig where jobname=?", jobname); if(count == 0) { String insert = "insert into jobconfig(jobname,jobdef) values(?,?)"; SQLExecutor.insertWithDBName("bigdata_conf",insert, jobname,jobdef); } else { String update = "update jobconfig set jobdef=? where jobname=?"; SQLExecutor.updateWithDBName("bigdata_conf",update, jobdef,jobname); } }
public static void saveDBJobstatic(DBJobstatic DBJobstatic) throws Exception { int count = SQLExecutor.queryObjectWithDBName(int.class,"bigdata_conf", "select count(1) from jobstatic where jobstaticid=?", DBJobstatic.getJobstaticid()); if(count == 0) { SQLExecutor.insertBean("bigdata_conf","insert into jobstatic(jobname,savetime,jobstatic,jobstaticid) values(#[jobname],#[savetime],#[jobstatic],#[jobstaticid])",DBJobstatic); } else { SQLExecutor.updateBean("bigdata_conf","update jobstatic set jobname=#[jobname],savetime=#[savetime],jobstatic=#[jobstatic] where jobstaticid=#[jobstaticid]",DBJobstatic); } } public static DBJob getDBJob(String jobname) throws Exception
+ "where PUBLISHOBJECT=? and REFERENCEOBJECT=? and PUBLISHTYPE=? and PUBLISH_SITE=? " + "and REFERENCETYPE=? and REFERENCE_SITE=?"; int num = SQLExecutor.queryObject(int.class, sql, pubobject, refobject, pubtype, SQLExecutor.insert(sql, pubobject, refobject, pubtype,
public Timestamp initpasswordupdatetime(int userid) throws ManagerException { try { Timestamp updatetime = SQLExecutor.queryObject(Timestamp.class, "select password_updatetime from TD_SM_USER where USER_ID=?", userid); if(updatetime == null) { updatetime = new Timestamp(new Date().getTime()); StringBuffer hsql = new StringBuffer(); hsql.append("update TD_SM_USER set password_updatetime=? where ").append( "USER_ID=?"); SQLExecutor.update(hsql.toString(), updatetime,userid); return updatetime; } return updatetime; } catch (Exception e) { throw new ManagerException(e); } } public boolean ishistorypassword(int userid,String password)throws ManagerException
SQLExecutor.queryObjectWithDBName(int.class,"bigdata_conf", exist); } catch (Exception e) { log.info("jobconfig table 不存在,创建jobconfig表:create table jobconfig (jobname string, jobdef string,PRIMARY KEY (jobname))。"); try { SQLExecutor.updateWithDBName("bigdata_conf","create table jobconfig (jobname string, jobdef string,PRIMARY KEY (jobname))"); log.info("创建jobconfig表成功:create table jobconfig (jobname string, jobdef string,PRIMARY KEY (jobname))。"); } catch (SQLException e1) { SQLExecutor.queryObjectWithDBName(int.class,"bigdata_conf", exist); } catch (Exception e) { log.info("jobstatic table 不存在,创建jobconfig表:create table jobstatic (jobstaticid string,jobname string, jobstatic TEXT,savetime number(10), PRIMARY KEY (jobstaticid))。"); try { SQLExecutor.updateWithDBName("bigdata_conf","create table jobstatic (jobstaticid string,jobname string, jobstatic TEXT,savetime number(10),PRIMARY KEY (jobstaticid))"); log.info("创建jobstatic表成功:create table jobstatic (jobstaticid string,jobname string, jobstatic TEXT,savetime number(10), PRIMARY KEY (jobstaticid))。"); } catch (SQLException e1) {
boolean isexist = SQLExecutor.queryObject(int.class,"SELECT count(*) counts FROM td_sm_orguser WHERE user_id = ?",userID_) > 0; if(isexist){ SQLExecutor.update("update td_sm_orguser set org_id=? where user_id=?" ,orgID,userID_); SQLExecutor.insert("INSERT into td_sm_orguser (org_id, user_id) VALUES (?, ?) " ,orgID,userID_);
SQLExecutor.queryWithDBNameByNullRowHandler(resultSetHandler, esjdbc.getDbConfig().getDbName(), esjdbc.getSql()); SQLExecutor.queryBeanWithDBNameByNullRowHandler(resultSetHandler, esjdbc.getDbConfig().getDbName(), esjdbc.getSql(), getParamValue());
protected void fetchPage() { if (pageSize <= 0) { try { if(rowhandler == null) returnValues = SQLExecutor.queryListWithDBName(clazz, dbname,sql); else returnValues = SQLExecutor.queryListWithDBNameByRowHandler(rowhandler,clazz, dbname,sql); } catch (Exception e) { throw new JRRuntimeException(e); } nextPage = false; } else { ListInfo listInfo = null; try { if(rowhandler == null) listInfo = SQLExecutor.moreListInfoWithDBName(clazz, dbname, sql, pageCount * pageSize, pageSize); else listInfo = SQLExecutor.moreListInfoWithDBNameByRowHandler(rowhandler,clazz, dbname, sql, pageCount * pageSize, pageSize); nextPage = listInfo.getMoreListInfo().isHasmore(); returnValues = listInfo.getDatas(); } catch (Exception e) { throw new JRRuntimeException(e); } } ++pageCount; initIterator(); }
public void updateCommentStatus(String docCommentId, int newStatus) throws DocCommentManagerException { // TODO Auto-generated method stub String sql = "update td_cms_doc_comment set status = ? where comment_id = ?"; try { SQLExecutor.update(sql, newStatus,Integer.parseInt(docCommentId)); } catch (SQLException e) { e.printStackTrace(); throw new DocCommentManagerException("更新指定评论的状态失败!" + e.getMessage()); } }
public static List<String> getAllJobNames() throws Exception { List<String> names = SQLExecutor.queryList(String.class, "select jobname from jobconfig"); return names; } public static void addOrUdate(String jobname,String jobdef) throws Exception
int dictnum = SQLExecutor.queryObject(int.class, isRepeat_sql, dicttype.getName()); if(dictnum>0){//有重复记录 return "-1"; SQLExecutor.queryByNullRowHandler(new NullRowHandler(){ SQLExecutor.queryByNullRowHandler(new NullRowHandler(){
public static void updateBean( String sql, Object bean,GetCUDResult getCUDResult) throws SQLException { // if(bean == null ) // return ; // List datas = new ArrayList(); // datas.add(bean); // updateBeans( null, sql, datas); updateBean((String)null, sql, bean, getCUDResult); }
public static <T> List<T> queryList(Class<T> beanType, String sql, Object... fields) throws SQLException { return queryListWithDBName(beanType,null, sql, fields); } /**
public static DBJobstatic getDBJobstatic(String jobname,String jobstaticid) throws Exception { return SQLExecutor.queryObjectWithDBName(DBJobstatic.class,"bigdata_conf", "select * from jobstatic where jobname=? and jobstaticid=?", jobname,jobstaticid); }
Map updatetimes = SQLExecutor.queryObjectByRowHandler(new RowHandler<HashMap>(){ hsql.append("update TD_SM_USER set password_updatetime=? where ").append( "USER_ID=?"); SQLExecutor.update(hsql.toString(), new Timestamp(new Date().getTime()),userid); return false;
protected void fetchPage() { if (pageSize <= 0) { try { returnValues = SQLExecutor.queryListWithDBName(HashMap.class, dbname,sql); } catch (Exception e) { throw new JRRuntimeException(e); } nextPage = false; } else { ListInfo listInfo = null; try { listInfo = SQLExecutor.moreListInfoWithDBName(HashMap.class, dbname, sql, pageCount * pageSize, pageSize); nextPage = listInfo.getMoreListInfo().isHasmore(); returnValues = listInfo.getDatas(); } catch (Exception e) { throw new JRRuntimeException(e); } } ++pageCount; initIterator(); }
public static <T> void executeBatch(String sql,List<T> datas,int batchsize, BatchHandler<T> batchHandler) throws SQLException{ executeBatch(null,sql,datas,batchsize, batchHandler); }
public void addStatus(Status currentStatus) throws Exception { SQLExecutor.insertWithDBName(dbname,insertSQL,currentStatus.getId(),currentStatus.getTime(),currentStatus.getLastValue(),lastValueType); } public void updateStatus(Status currentStatus) throws Exception {