private void saveUser(String userId, String jobId, String orgId, int samesn) { try { String jobsnsql = "select c.job_sn from td_sm_orgjob c where c.org_id ='" + orgId + "' and c.job_id='" + jobId + "'"; DBUtil temp = new DBUtil(); temp.executeSelect(jobsnsql); String jobsn = "1"; if (temp.size() > 0) jobsn = temp.getInt(0, 0) + ""; DBUtil db = new DBUtil(); String sql = "insert into td_sm_userjoborg" + " (user_id,job_id,org_id,JOB_SN,SAME_JOB_USER_SN,JOB_STARTTIME,JOB_FETTLE)" + " values(" + userId + ",'" + jobId + "','" + orgId + "'," + jobsn + "," + samesn + "," + DBUtil.getDBAdapter().to_date(new Date()) + ",1)"; db.executeInsert(sql); } catch (Exception e) { e.printStackTrace(); } }
/** * 执行批处理命令,执行批处理命令之前可以指定特定的数据库连接池的名称 * * @return 如果是插入批处理那么返回所有产生的主键 * @throws Exception */ public Object[] executeBatch() throws SQLException { return this.executeBatch((String)null); }
public boolean deleteDsrc(int docsrcid) throws DocsourceManagerException { boolean b = true; DBUtil db = new DBUtil(); String sql="delete from TD_CMS_DOCSOURCE where DOCSOURCE_ID="+ docsrcid +""; try { db.executeDelete(sql); } catch (SQLException e) { b = false; // e.printStackTrace(); } return b; }
/** * 判断频道是否存在 */ public boolean channelIsExist(String channelID) { DBUtil dbutil = new DBUtil(); try { dbutil.executeSelect("select channel_id from td_cms_channel where channel_id=" + channelID); return dbutil.size() > 0; } catch (Exception e) { return false; } }
public String getUserMainOrgId(String userId) { String sql = " select * from td_sm_orguser where user_id='" + userId + "'"; DBUtil db = new DBUtil(); String orgId = ""; try { db.executeSelect(sql); orgId = db.getString(0, "org_id"); } catch (SQLException e) { e.printStackTrace(); } return orgId; }
DBUtil db = new DBUtil(); DBUtil db_del = new DBUtil(); try { db.executeSelect(sql.toString()); if(db.size() > 0){ state = false; }else{ db_del.addBatch(roleresop); db_del.addBatch(deljob); db_del.executeBatch(); state = true;
public void pigeonholeDoc(int docid, int userId) throws DocumentManagerException { DBUtil db = new DBUtil(); String sqlUpdate = "update td_cms_document set status = 7, guidangtime = " + DBUtil.getDBAdapter().to_date(new Date()) + ",guidangman=" + userId + " where document_id=" + docid; try { db.executeUpdate(sqlUpdate); if (ArrangeDocExist(String.valueOf(docid))) { String sqlDel = "delete Td_Cms_Doc_Arrange where document_id=" + docid + ""; db.executeDelete(sqlDel); } } catch (SQLException e) { e.printStackTrace(); throw new DocumentManagerException("归档时出现异常" + e.getMessage()); } }
/** * <p> * 批量执行数据库方法 * </p> * * @param sqls * @return boolean * @throws ManagerException */ public Object[] executeBatch(String[] sqls) throws ManagerException { if (sqls != null && sqls.length > 0) { DBUtil dbUtil = new DBUtil(); // dbUtil.setAutoCommit(false); try { for (int loop = 0; loop < sqls.length; loop++) { dbUtil.addBatch(sqls[loop]); } return dbUtil.executeBatch(); } catch (Exception e) { e.printStackTrace(); logger.error("executeBatch() -> \n", e); } finally { dbUtil.resetBatch(); dbUtil = null; } } return null; }
public int addOneTask(int docid, int preTaskId, int preStatus, int submitId, int[] executerIds) throws DocumentManagerException { DBUtil db = new DBUtil(); String sql = ""; long taskId = -1; try { taskId = db.getNextPrimaryKey("td_cms_doc_task"); if (preTaskId != 0) sql = "insert into td_cms_doc_task(TASK_ID,pre_task_id,document_id,pre_status,submit_id,submit_time) " + "values(" + taskId + "," + preTaskId + "," + docid + "," + preStatus + "," + submitId + "," + DBUtil.getDBAdapter().to_date(new Date()) + ")"; else sql = "insert into td_cms_doc_task(TASK_ID,document_id,pre_status,submit_id,submit_time) " + "values(" + taskId + "," + docid + "," + preStatus + "," + submitId + "," + DBUtil.getDBAdapter().to_date(new Date()) + ")"; db.executeInsert(sql); // 往任务表中增加一条任务 // 在任务明细表中为每一个执行人添加一条任务 for (int i = 0; i < executerIds.length; i++) { sql = "insert into td_cms_doc_task_detail(task_id,performer)" + "values(" + taskId + "," + executerIds[i] + ")"; db.executeInsert(sql); } } catch (Exception se) { se.printStackTrace(); throw new DocumentManagerException("新增任务失败" + se.getMessage()); } return (int) taskId; }
public boolean updateRes(String resId, String path, String title){ boolean state = false; String sql = "update td_sm_res set TITLE='" + title + "',PATH='" + path + "' " + "where RES_ID ='" + resId + "'"; DBUtil db = new DBUtil(); try { db.executeUpdate(sql); state = true; } catch (SQLException e) { e.printStackTrace(); } return state; }
/** * 删除置顶文档 * * @param docId * @return boolean * @throws DocumentManagerException */ public boolean delArrangeDoc(String[] docId) throws DocumentManagerException { boolean flag = false; DBUtil db = new DBUtil(); try { for (int i = 0; i < docId.length; i++) { String sql = "delete from TD_CMS_DOC_ARRANGE where document_id = " + docId[i]; // db.executeDelete(sql); db.addBatch(sql); flag = true; } if (flag) db.executeBatch(); } catch (Exception e) { e.printStackTrace(); throw new DocumentManagerException(e.getMessage()); } return flag; }
public void completeOneTask(int taskId, int desStatus, int performer, String opinion) throws DocumentManagerException { DBUtil db1 = new DBUtil(); if (opinion == null) opinion = ""; try { String sql = ""; // 将当前执行人performer的待审任务更新,填写任务完成时间和审核意见等 sql = "update td_cms_doc_task_detail set complete_time =" + DBUtil.getDBAdapter().to_date(new Date()) + ",after_status = " + desStatus + ",opinion='" + opinion + "' where valid = 1 " + "and task_id =" + taskId + " and performer =" + performer; db1.executeUpdate(sql); // 将非当前执行人performer的待审任务置为无效 sql = "update td_cms_doc_task_detail set valid = 0 where valid = 1" + " and task_id =" + taskId + " and performer !=" + performer; db1.executeUpdate(sql); } catch (Exception se) { se.printStackTrace(); throw new DocumentManagerException("完成任务更新失败" + se.getMessage()); } }
/** * 测试带前缀的表主键的生成机制测试方法 * */ public static void testprekeygenerator() { DBUtil dbutil = new DBUtil(); try { dbutil.executeInsert("insert into testpre(name) values('test')"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public int getDocCitedType(String citedDocId) throws DocumentManagerException { String sql = "select citetype from td_cms_chnl_ref_doc where doc_id =" + citedDocId; DBUtil db = new DBUtil(); try { db.executeSelect(sql); if (db.size() > 0) return db.getInt(0, "citetype"); } catch (Exception sqle) { sqle.printStackTrace(); throw new DocumentManagerException("获取引用文档类型时数据库操作失败:" + sqle.getMessage()); } return -1; }
public void citeDoc(int docid, int channelid, int userid, int type, int siteid) throws DocumentManagerException { DBUtil db = new DBUtil(); String sql; try { sql = "insert into td_cms_chnl_ref_doc(chnl_id,doc_id,op_user_id,op_time,citetype,site_id) values(" + channelid + "," + docid + "," + userid + "," + DBUtil.getDBAdapter().to_date(new Date()) + "," + type + "," + siteid + ")"; db.executeInsert(sql); } catch (SQLException se) { se.printStackTrace(); throw new DocumentManagerException("引用文档时数据库操作失败" + se.getMessage()); } }
public List getSubOrgList(String orgId)throws ManagerException { List subOrgList = new ArrayList(); try { // String sql = "SELECT * FROM TD_SM_ORGANIZATION t " + // "START WITH t.org_id = '" + orgId + "' " + // "CONNECT BY PRIOR t.org_id = t.PARENT_ID"; String concat_ = DBUtil.getDBAdapter().concat(" org_tree_level","'|%' "); String sql = "SELECT * FROM TD_SM_ORGANIZATION t where t.org_tree_level like (select " + concat_ + " from TD_SM_ORGANIZATION c where c.org_id = "+ orgId+ ") or t.org_id = " + orgId; // System.out.println(sql); DBUtil db = new DBUtil(); db.executeSelect(sql); subOrgList = this.dbutilToOrganziationList(db); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return subOrgList; }
public void storeUserrole(String userId, String roleId) throws ManagerException { DBUtil db = new DBUtil(); DBUtil dbl = new DBUtil(); try { String sql = "select count(*) from td_sm_userrole where " + " user_id = " + userId + " and role_id ='" + roleId + "'"; dbl.executeSelect(sql); if (dbl.getInt(0, 0) == 0) { String sqlins = "insert into td_sm_userrole(user_id,role_id) " + " values(" + userId + ",'" + roleId + "')"; db.executeInsert(sqlins); } Event event = new EventImpl("", ACLEventType.RESOURCE_ROLE_INFO_CHANGE); super.change(event); } catch (Exception e) { e.printStackTrace(); throw new ManagerException(e.getMessage()); } }
public static void main(String[] args) throws SQLException { String concat = DBUtil.getDBAdapter().concat("'来自用户自身角色【'","b.role_name","'】'"); System.out.println(concat); // updateOrg("0"); // updateGroup("0"); }
void update() { String sql = "update test set name=''"; for(int i = 0; i < 1000;i ++) { DBUtil dbUtil = new DBUtil(); try { dbUtil.executeUpdate("oadx",sql); System.out.println("Thread[" + j + "] " + i + " dbUtil.size:" + dbUtil.size()); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
public List getGroupList(String hql) throws ManagerException { List list = new ArrayList(); try { DBUtil db = new DBUtil(); db.executeSelect(hql); list = this.dbutilToGroupList(db); } catch (Exception e) { logger.error("",e); } return list; } public List getChildGroupList(String groupid) throws ManagerException{