List of usage examples for org.springframework.dao DataAccessException toString
public String toString()
From source file:com.virtusa.akura.student.controller.CoCurricularActivityController.java
/** * Delete student Sport details.// w w w.j a v a 2 s . c o m * * @param request - HttpServletRequest * @param session - HttpSession * @param model - ModelMap * @return name of the view which is redirected to. * @throws AkuraAppException - if error occurs when deleting a studentSport instance. */ @RequestMapping(value = ACTION_FOR_DELETE_STUDENT_SPORT, method = RequestMethod.POST) public String deleteStudentSport(HttpServletRequest request, HttpSession session, ModelMap model) throws AkuraAppException { String strStSportId = request.getParameter(SELECTED_STUDENT_SPORT_ID); int stSportId = Integer.parseInt(strStSportId); try { studentService.deleteStudentSport(stSportId); } catch (DataAccessException ex) { LOG.error("ManageCoCurricularActivityController - error occured while deleting StudentSport " + "-->" + ex.toString()); throw new AkuraAppException(AkuraWebConstant.HIBERNATE_INVALID_DEL_OPERATION, ex); } catch (AkuraAppException ex) { LOG.error("ManageCoCurricularActivityController - error occured while deleting studentSport object " + "-->" + ex.toString()); throw new AkuraAppException(AkuraWebConstant.HIBERNATE_INVALID_DEL_OPERATION, ex); } return populateStudentCoCurricularData(request, session, model); }
From source file:com.virtusa.akura.student.controller.CoCurricularActivityController.java
/** * Delete Sport details.//from w ww. j a v a 2 s .c o m * * @param request - HttpServletRequest * @param session - HttpSession * @param model - ModelMap * @return name of the view which is redirected to. * @throws AkuraAppException - if error occurs when deleting a Sport instance. */ @RequestMapping(value = ACTION_FOR_DELETE_STUDENT_CLUB_SOCIETY, method = RequestMethod.POST) public String deleteStudentClubsociety(HttpServletRequest request, HttpSession session, ModelMap model) throws AkuraAppException { String strStClubSocietyId = request.getParameter(SELECTED_STUDENT_CLUB_SOCIETY_ID); int stClubSocietyId = Integer.parseInt(strStClubSocietyId); try { studentService.deleteStudentClubSocietyDetail(stClubSocietyId); } catch (StudentClubAndSocietyAchievementDeleteException e) { model.addAttribute(ERROR_DELETE_CLUB_SOCIETY, e.getErrorCode()); } catch (DataAccessException ex) { LOG.error("ManageCoCurricularActivityController - error occured while deleting StudentClubSociety " + "-->" + ex.toString()); throw new AkuraAppException(AkuraWebConstant.HIBERNATE_INVALID_DEL_OPERATION, ex); } catch (AkuraAppException ex) { LOG.error( "ManageCoCurricularActivityController - error occured while deleting studentClubSociety object " + "-->" + ex.toString()); throw new AkuraAppException(AkuraWebConstant.HIBERNATE_INVALID_DEL_OPERATION, ex); } return populateStudentCoCurricularData(request, session, model); }
From source file:org.sakaiproject.lessonbuildertool.model.SimplePageToolDaoImpl.java
public boolean quickSaveItem(Object o) { try {//from w w w . j ava 2 s . c o m Object id = getHibernateTemplate().save(o); return true; } catch (DataAccessException e) { e.printStackTrace(); log.warn("Hibernate could not save: " + e.toString()); return false; } }
From source file:org.sakaiproject.lessonbuildertool.model.SimplePageToolDaoImpl.java
public boolean deleteItem(Object o) { /*/*from w w w . j a v a 2s . co m*/ * If o is SimplePageItem or SimplePage, it makes sure it gets the right page and checks the * permissions on it. If the item isn't SimplePageItem or SimplePage, it lets it go. * * Essentially, if any of those say that the edit is fine, it won't throw the error. */ if (!(o instanceof SimplePageItem && canEditPage(((SimplePageItem) o).getPageId())) && !(o instanceof SimplePage && canEditPage((SimplePage) o)) && (o instanceof SimplePage || o instanceof SimplePageItem)) { return false; } if (o instanceof SimplePageItem) { SimplePageItem i = (SimplePageItem) o; EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/item/" + i.getId(), true)); } else if (o instanceof SimplePage) { SimplePage i = (SimplePage) o; EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/page/" + i.getPageId(), true)); } else if (o instanceof SimplePageComment) { SimplePageComment i = (SimplePageComment) o; EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/comment/" + i.getId(), true)); } try { getHibernateTemplate().delete(o); return true; } catch (DataAccessException e) { try { /* If we have multiple objects of the same item, you must merge them * before deleting. If the first delete fails, we merge and try again. */ getHibernateTemplate().delete(getHibernateTemplate().merge(o)); return true; } catch (DataAccessException ex) { ex.printStackTrace(); log.warn("Hibernate could not delete: " + e.toString()); return false; } } }
From source file:info.smartkit.hairy_batman.query.SogouSearchQuery.java
public void parseWxOpenId() { Document doc;/*from w w w . j a v a2s . c o m*/ try { // need http protocol // doc = Jsoup.connect(GlobalConsts.SOGOU_SEARCH_URL_BASE+ wxFoo.getSubscribeId()).get(); doc = Jsoup.connect("http://weixin.sogou.com/weixin?type=1&query=" + wxFoo.getSubscribeId() + "&fr=sgsearch&ie=utf8&_ast=1423915648&_asf=null&w=01019900&cid=null&sut=19381").get(); LOG.debug("openID html INFO:" + doc.html()); // get page title String title = doc.title(); LOG.debug("title : " + title); // get all "?:" value of html <span> //Elements openIdLink = doc.select(GlobalConsts.SOGOU_SEARCH_WX_OPEN_ID_HTML_ELEMENTS).select(GlobalConsts.SOGOU_SEARCH_WX_OPEN_ID_HTML_ELE_IDENTITY); Elements openIdLink = doc.getElementsByClass("wx-rb"); Element a = null; String openIdLinkHref = ""; if (openIdLink != null && openIdLink.size() > 0) { Iterator<Element> itea = openIdLink.iterator(); while (itea.hasNext()) { a = itea.next(); LOG.debug("openID html INFO:" + a.html()); if (a.getElementsByTag("em").html().indexOf(wxFoo.getSubscribeId()) != -1) { break; } } } if (a != null) { openIdLinkHref = a.attr("href"); } LOG.debug("openIdLinkHref:" + openIdLinkHref); // FIXME:???? if (this.wxFoo.getOpenId() == null && openIdLinkHref.length() > 0) { this.wxFoo.setOpenId(openIdLinkHref.split(GlobalConsts.SOGOU_SEARCH_WX_OPEN_ID_KEYWORDS)[1]); LOG.info("saved wxOpenId value: " + this.wxFoo.getOpenId()); GlobalVariables.wxFooListWithOpenId.add(this.wxFoo); // File reporting new FileReporter(GlobalConsts.REPORT_FILE_OUTPUT_OPENID, GlobalVariables.wxFooListWithOpenId, FileReporter.REPORTER_TYPE.R_T_OPENID, FileReporter.REPORTER_FILE_TYPE.EXCEL).write(); // Then,OpenID JSON site parse if (this.wxFoo.getOpenId() != null) { // Save openId to DB. try { GlobalVariables.jdbcTempate.update("insert into " + GlobalConsts.QUERY_TABLE_NAME_BASIC + "(id,store,agency,unit,subscribeId,onSubscribe,code,openId) values(?,?,?,?,?,?,?,?)", new Object[] { this.wxFoo.getId(), this.wxFoo.getStore(), this.wxFoo.getAgency(), this.wxFoo.getUnit(), this.wxFoo.getSubscribeId(), this.wxFoo.getOnSubscribe(), this.wxFoo.getCode(), this.wxFoo.getOpenId() }, new int[] { java.sql.Types.INTEGER, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR }); this.parseSogouJsonSite(this.wxFoo.getOpenId()); } catch (DataAccessException e) { e.printStackTrace(); } } else { LOG.warn("SogouSearchQuery getOpenId Failure! site info:" + wxFoo.getCode()); // TODO write those info to File or DB for collect which // agency not open weixin service // Save openId to DB. try { GlobalVariables.jdbcTempate.update("insert into " + GlobalConsts.QUERY_TABLE_NAME_BASIC + "(id,store,agency,unit,subscribeId,onSubscribe,code,openId) values(?,?,?,?,?,?,?,?)", new Object[] { this.wxFoo.getId(), this.wxFoo.getStore(), this.wxFoo.getAgency(), this.wxFoo.getUnit(), this.wxFoo.getSubscribeId(), this.wxFoo.getOnSubscribe(), this.wxFoo.getCode(), "" }, new int[] { java.sql.Types.INTEGER, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR, java.sql.Types.VARCHAR }); LOG.warn("Can not get subsriber info: " + this.wxFoo.getCode()); this.parseSogouJsonSite(this.wxFoo.getOpenId()); } catch (DataAccessException e) { e.printStackTrace(); } } } } catch (IOException e) { // e.printStackTrace(); LOG.error(e.toString()); } }
From source file:com.qut.middleware.deployer.logic.RegisterESOELogic.java
private void configureDataLayer(DeploymentBean bean) throws RegisterESOEException { switch (bean.getDatabaseDriver()) { case mysql:/*from w w w . jav a2 s .co m*/ dataSource.setDriverClassName(Constants.MYSQL_DRIVER); break; case oracle: dataSource.setDriverClassName(Constants.ORACLE_DRIVER); break; /* Attempt to connect to mysql source if not submitted */ default: dataSource.setDriverClassName(Constants.MYSQL_DRIVER); } try { dataSource.setUrl(bean.getDatabaseURL()); dataSource.setUsername(bean.getDatabaseUsername()); dataSource.setPassword(bean.getDatabasePassword()); } catch (DataAccessException e) { this.logger.error("Unable to connect with database " + e.getLocalizedMessage()); this.logger.debug(e.toString()); throw new RegisterESOEException(e.getLocalizedMessage(), e); } }
From source file:tw.edu.chit.service.impl.AdminManagerImpl.java
public Map<String, String> txImportNewStudent(List<TempStmd> students) throws DataAccessException { Map ret = new HashMap<String, String>(); String hql = "From Student Where studentNo=?"; String hql_1 = "From RegistrationCard Where Oid=?"; String hql_2 = "From WwPass Where username=?"; String hql_3 = "From StdImage4t Where Oid=?"; String hql_0 = "From StdImage Where studentNo=?"; List<RegistrationCard> RegCards = new LinkedList<RegistrationCard>(); List<WwPass> Passes = new LinkedList<WwPass>(); List<StdImage4t> StdImg4t = new LinkedList<StdImage4t>(); List<StdImage> StdImg = new LinkedList<StdImage>(); List<Student> studs = new ArrayList<Student>(); List<String> nonImport = new ArrayList<String>(); Student student = null;/*w w w. j ava 2s . c om*/ Integer imgOid = null; int icnt = 0; String studentNo = ""; for (TempStmd stmd : students) { try { studentNo = stmd.getStudentNo(); //step 0.?? Stdimage4t-> StdImage StdImg = find(hql_0, new Object[] { studentNo }); if (StdImg.isEmpty()) { if (stmd.getImageOid() != null) { StdImg4t = find(hql_3, new Object[] { stmd.getImageOid() }); if (!StdImg4t.isEmpty()) { StdImage4t img4t = StdImg4t.get(0); StdImage img = new StdImage(); img.setStudentNo(studentNo); img.setImage(img4t.getImage()); dao.saveObject(img); dao.reload(img); imgOid = img.getOid(); } } } //step 1.? studs = (List<Student>) find(hql, new Object[] { studentNo }); if (studs.isEmpty()) { student = new Student(); student.setDepartClass(stmd.getDepartClass()); student.setStudentNo(studentNo); student.setStudentName(stmd.getStudentName()); student.setIdno(stmd.getIdno()); student.setSex(stmd.getSex()); student.setBirthday(stmd.getBirthday()); student.setEntrance(stmd.getEntrance()); student.setIdent(stmd.getIdent()); student.setSchlName(stmd.getSchlName() == null ? "" : stmd.getSchlName()); student.setSchlCode(stmd.getSchlCode() == null ? "" : stmd.getSchlCode()); student.setGradDept(stmd.getGradDept() == null ? "" : stmd.getGradDept()); student.setGradyear(stmd.getGradyear() == null ? null : stmd.getGradyear()); student.setGraduStatus(stmd.getGraduStatus() == null ? "" : stmd.getGraduStatus()); student.setCurrPost(stmd.getCurrPost() == null ? "" : stmd.getCurrPost()); student.setCurrAddr(stmd.getCurrAddr() == null ? "" : stmd.getCurrAddr()); student.setTelephone(stmd.getTelephone() == null ? "" : stmd.getTelephone()); student.setCellPhone(stmd.getCellPhone() == null ? "" : stmd.getCellPhone()); student.setParentName(stmd.getParentName() == null ? "" : stmd.getParentName()); student.setEmail(stmd.getEmail() == null ? "" : stmd.getEmail()); student.setPermPost(stmd.getPermPost() == null ? "" : stmd.getPermPost()); student.setPermAddr(stmd.getPermAddr() == null ? "" : stmd.getPermAddr()); student.setBirthCounty(stmd.getBirthCounty()); student.setBirthProvince(stmd.getBirthProvince()); student.setDivi(stmd.getDivi()); student.setStudentEname(stmd.getStudentEname()); dao.saveObject(student); //step 2.RegistrationCardstudentNo RegCards = find(hql_1, new Object[] { stmd.getRegistrationCardOid() }); if (!RegCards.isEmpty()) { RegistrationCard rc = RegCards.get(0); rc.setStudentNo(studentNo); dao.saveObject(rc); } else { //Error?! } //setp 3. Passes = find(hql_2, new Object[] { studentNo }); if (Passes.isEmpty()) { WwPass pass = new WwPass(); pass.setUsername(stmd.getStudentNo()); pass.setPassword(stmd.getIdno()); pass.setInformixPass(stmd.getIdno()); pass.setPriority("C"); pass.setUpdated(Calendar.getInstance().getTime()); dao.saveObject(pass); } icnt++; } else { nonImport.add(studentNo); // Passes = find(hql_2, new Object[] { studentNo }); if (Passes.isEmpty()) { WwPass pass = new WwPass(); pass.setUsername(stmd.getStudentNo()); pass.setPassword(stmd.getIdno()); pass.setInformixPass(stmd.getIdno()); pass.setPriority("C"); pass.setUpdated(Calendar.getInstance().getTime()); dao.saveObject(pass); } } } catch (DataAccessException e) { log.error(e.toString()); //ret.put("error", stmd.getStudentNo()); //return ret; throw e; } } ret.put("importCount", icnt); ret.put("nonImport", nonImport); return ret; }