List of usage examples for java.sql Connection isClosed
boolean isClosed() throws SQLException;
Connection
object has been closed. From source file:pivotal.au.se.gemfirexdweb.controller.GatewaySenderController.java
@RequestMapping(value = "/gatewaysenders", method = RequestMethod.GET) public String showGatewaySenders(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { int startAtIndex = 0, endAtIndex = 0; javax.servlet.jsp.jstl.sql.Result allGatewaySenderInfoResult, runningGatewaySenders = null; if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {//from w w w . ja v a2s .c o m Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to show gateway senders"); GatewaySenderDAO gsDAO = GemFireXDWebDAOFactory.getGatewaySenderDAO(); Result result = new Result(); String gsAction = request.getParameter("gsAction"); if (gsAction != null) { logger.debug("gsAction = " + gsAction); if (gsAction.equals("ALLGATEWAYSENDERINFO")) { allGatewaySenderInfoResult = gsDAO.getGatewaySenderInfo((String) request.getParameter("senderId"), (String) session.getAttribute("user_key")); model.addAttribute("allGatewaySenderInfoResult", allGatewaySenderInfoResult); model.addAttribute("gatewaysender", (String) request.getParameter("senderId")); } else if (gsAction.equals("RUNNINGGATEWAYSENDERS")) { runningGatewaySenders = gsDAO.getRunningGatewaySenders((String) request.getParameter("senderId"), (String) session.getAttribute("user_key")); model.addAttribute("runningGatewaySenders", runningGatewaySenders); model.addAttribute("gatewaysender", (String) request.getParameter("senderId")); } else { result = null; result = gsDAO.simplegatewaySenderCommand((String) request.getParameter("senderId"), gsAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } } List<GatewaySender> gatewaysenders = gsDAO.retrieveGatewaySenderList( (String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key")); model.addAttribute("records", gatewaysenders.size()); model.addAttribute("estimatedrecords", gatewaysenders.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (gatewaysenders.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("gatewaysenders", gatewaysenders); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > gatewaysenders.size()) { endAtIndex = gatewaysenders.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = gatewaysenders.subList(startAtIndex, endAtIndex); model.addAttribute("gatewaysenders", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/gatewaysenders.jsp return "gatewaysenders"; }
From source file:pivotal.au.se.gemfirexdweb.controller.GatewaySenderController.java
@RequestMapping(value = "/gatewaysenders", method = RequestMethod.POST) public String performGatewaySendersAction(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {// w w w . ja v a2 s . c o m Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } int startAtIndex = 0, endAtIndex = 0; Result result = new Result(); List<GatewaySender> gatewaysenders = null; logger.debug("Received request to perform an action on the gateway senders"); GatewaySenderDAO gsDAO = GemFireXDWebDAOFactory.getGatewaySenderDAO(); if (request.getParameter("search") != null) { gatewaysenders = gsDAO.retrieveGatewaySenderList((String) session.getAttribute("schema"), (String) request.getParameter("search"), (String) session.getAttribute("user_key")); model.addAttribute("search", (String) request.getParameter("search")); } else { String[] tableList = request.getParameterValues("selected_gatewaysenders[]"); String commandStr = request.getParameter("submit_mult"); logger.debug("tableList = " + Arrays.toString(tableList)); logger.debug("command = " + commandStr); // start actions now if tableList is not null if (tableList != null) { List al = new ArrayList<Result>(); for (String senderId : tableList) { result = null; result = gsDAO.simplegatewaySenderCommand(senderId, commandStr, (String) session.getAttribute("user_key")); al.add(result); } model.addAttribute("arrayresult", al); } gatewaysenders = gsDAO.retrieveGatewaySenderList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key")); } model.addAttribute("records", gatewaysenders.size()); model.addAttribute("estimatedrecords", gatewaysenders.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (gatewaysenders.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("gatewaysenders", gatewaysenders); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > gatewaysenders.size()) { endAtIndex = gatewaysenders.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = gatewaysenders.subList(startAtIndex, endAtIndex); model.addAttribute("gatewaysenders", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/gatewaysenders.jsp return "gatewaysenders"; }
From source file:org.jxstar.dao.pool.PooledConnection.java
/** * ?/*from ww w. ja v a2s . co m*/ * ?queueConnect?????5 * ?1???5??? * ?validTest?validQuery?validIdle * * @param DataSourceConfig -- ??? * @return */ private Connection getConnectionFromSelf(DataSourceConfig dsConfig) { Connection conn = null; DataSource ds = createSelfDataSource(dsConfig); boolean catchError = dsConfig.isCatchError(); try { conn = ds.getConnection(); //_log.showDebug("get connection is:" + conn); if (conn == null || conn.isClosed()) { String dsName = dsConfig.getDataSourceName(); _log.showError("datasource [{0}] get connection is null!", dsName); return null; } int iTranLevel = getTranLevelConstant(dsConfig.getTranLevel()); conn.setAutoCommit(false); conn.setTransactionIsolation(iTranLevel); } catch (SQLException e) { if (catchError) { _log.showError(e); } } return conn; }
From source file:pivotal.au.se.gemfirexdweb.controller.ViewController.java
@RequestMapping(value = "/views", method = RequestMethod.GET) public String showTables(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { int startAtIndex = 0, endAtIndex = 0; String schema = null;/*from ww w .ja va2 s . c o m*/ if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to show views"); ViewDAO viewDAO = GemFireXDWebDAOFactory.getViewDAO(); Result result = new Result(); String viewAction = request.getParameter("viewAction"); String selectedSchema = request.getParameter("selectedSchema"); logger.debug("selectedSchema = " + selectedSchema); if (selectedSchema != null) { schema = selectedSchema; } else { schema = (String) session.getAttribute("schema"); } logger.debug("schema = " + schema); if (viewAction != null) { logger.debug("viewAction = " + viewAction); result = null; result = viewDAO.simpleviewCommand(schema, (String) request.getParameter("viewName"), viewAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } List<View> views = viewDAO.retrieveViewList(schema, null, (String) session.getAttribute("user_key")); model.addAttribute("records", views.size()); model.addAttribute("estimatedrecords", views.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (views.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("views", views); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > views.size()) { endAtIndex = views.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = views.subList(startAtIndex, endAtIndex); model.addAttribute("views", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); model.addAttribute("chosenSchema", schema); // This will resolve to /WEB-INF/jsp/views.jsp return "views"; }
From source file:pivotal.au.se.gemfirexdweb.controller.IndexController.java
@RequestMapping(value = "/indexes", method = RequestMethod.GET) public String showInexes(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { int startAtIndex = 0, endAtIndex = 0; String schema = null;//from w w w .j ava2 s . co m if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to show indexes"); IndexDAO indexDAO = GemFireXDWebDAOFactory.getIndexDAO(); Result result = new Result(); String idxAction = request.getParameter("idxAction"); String selectedSchema = request.getParameter("selectedSchema"); logger.debug("selectedSchema = " + selectedSchema); if (selectedSchema != null) { schema = selectedSchema; } else { schema = (String) session.getAttribute("schema"); } logger.debug("schema = " + schema); if (idxAction != null) { logger.debug("idxAction = " + idxAction); result = null; result = indexDAO.simpleindexCommand(schema, (String) request.getParameter("indexName"), idxAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } List<Index> indexes = indexDAO.retrieveIndexList(schema, null, (String) session.getAttribute("user_key")); model.addAttribute("records", indexes.size()); model.addAttribute("estimatedrecords", indexes.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (indexes.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("indexes", indexes); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > indexes.size()) { endAtIndex = indexes.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = indexes.subList(startAtIndex, endAtIndex); model.addAttribute("indexes", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); model.addAttribute("chosenSchema", schema); // This will resolve to /WEB-INF/jsp/indexes.jsp return "indexes"; }
From source file:pivotal.au.se.gemfirexdweb.controller.GatewayReceiverController.java
@RequestMapping(value = "/gatewayreceivers", method = RequestMethod.GET) public String showGatewayReceivers(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { int startAtIndex = 0, endAtIndex = 0; javax.servlet.jsp.jstl.sql.Result allGatewayRecieverInfoResult = null; if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/*from w ww.j ava2 s .c om*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to show gateway recievers"); GatewayReceiverDAO grDAO = GemFireXDWebDAOFactory.getGatewayRecieverDAO(); Result result = new Result(); String grAction = request.getParameter("grAction"); if (grAction != null) { logger.debug("grAction = " + grAction); if (grAction.equals("ALLGATEWAYRECIEVERINFO")) { allGatewayRecieverInfoResult = grDAO.getGatewayRecieverInfo((String) request.getParameter("id"), (String) session.getAttribute("user_key")); model.addAttribute("allGatewayRecieverInfoResult", allGatewayRecieverInfoResult); model.addAttribute("gatewayreciever", (String) request.getParameter("id")); } else { result = null; result = grDAO.simplegatewayReceiverCommand((String) request.getParameter("id"), grAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } } List<GatewayReceiver> gatewayreceivers = grDAO.retrieveGatewayReceiverList( (String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key")); model.addAttribute("records", gatewayreceivers.size()); model.addAttribute("estimatedrecords", gatewayreceivers.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (gatewayreceivers.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("gatewayreceivers", gatewayreceivers); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > gatewayreceivers.size()) { endAtIndex = gatewayreceivers.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = gatewayreceivers.subList(startAtIndex, endAtIndex); model.addAttribute("gatewayreceivers", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/gatewayreceivers.jsp return "gatewayreceivers"; }
From source file:pivotal.au.se.gemfirexdweb.controller.DiskStoreController.java
@RequestMapping(value = "/diskstores", method = RequestMethod.GET) public String showDiskstores(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/gemfirexdweb/login"); return null; } else {/*from ww w .ja va2s . c o m*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to show diskstores"); int startAtIndex = 0, endAtIndex = 0; javax.servlet.jsp.jstl.sql.Result allDiskStoreInfoResult = null; String schema = null; DiskStoreDAO dsDAO = GemFireXDWebDAOFactory.getDiskStoreDAO(); Result result = new Result(); String dsAction = request.getParameter("dsAction"); if (dsAction != null) { logger.debug("dsAction = " + dsAction); if (dsAction.equals("ALLDISKSTOREINFO")) { allDiskStoreInfoResult = dsDAO.getDiskstoreInfo((String) request.getParameter("dsName"), (String) session.getAttribute("user_key")); model.addAttribute("allDiskStoreInfoResult", allDiskStoreInfoResult); model.addAttribute("dsName", (String) request.getParameter("dsName")); } else { result = null; result = dsDAO.simplediskStoreCommand((String) request.getParameter("dsName"), dsAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } } List<DiskStore> dsks = dsDAO.retrieveDiskStoreList("", null, (String) session.getAttribute("user_key")); model.addAttribute("records", dsks.size()); model.addAttribute("estimatedrecords", dsks.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (dsks.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("diskstores", dsks); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > dsks.size()) { endAtIndex = dsks.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = dsks.subList(startAtIndex, endAtIndex); model.addAttribute("diskstores", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/diskstores.jsp return "diskstores"; }
From source file:pivotal.au.se.gemfirexdweb.controller.HdfsStoreController.java
@RequestMapping(value = "/hdfsstores", method = RequestMethod.GET) public String showHdfsstores(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/*from ww w .j a v a 2 s . c o m*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to show hdfs stores"); int startAtIndex = 0, endAtIndex = 0; javax.servlet.jsp.jstl.sql.Result allHdfsStoreInfoResult = null; String schema = null; HdfsStoreDAO hdfsDAO = GemFireXDWebDAOFactory.getHdfsStoreDAO(); Result result = new Result(); String hdfsAction = request.getParameter("hdfsAction"); if (hdfsAction != null) { logger.debug("hdfsAction = " + hdfsAction); if (hdfsAction.equals("ALLHDFSSTOREINFO")) { allHdfsStoreInfoResult = hdfsDAO.getHdfsStoreInfo((String) request.getParameter("hdfsName"), (String) session.getAttribute("user_key")); model.addAttribute("allHdfsStoreInfoResult", allHdfsStoreInfoResult); model.addAttribute("hdfsName", (String) request.getParameter("hdfsName")); } else { result = null; result = hdfsDAO.simplehdfsStoreCommand((String) request.getParameter("hdfsName"), hdfsAction, (String) session.getAttribute("user_key")); model.addAttribute("result", result); } } List<HdfsStore> hdfsStores = hdfsDAO.retrieveHdfsStoreList("", null, (String) session.getAttribute("user_key")); model.addAttribute("records", hdfsStores.size()); model.addAttribute("estimatedrecords", hdfsStores.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (hdfsStores.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("hdfsstores", hdfsStores); } else { if (request.getParameter("startAtIndex") != null) { startAtIndex = Integer.parseInt(request.getParameter("startAtIndex")); } if (request.getParameter("endAtIndex") != null) { endAtIndex = Integer.parseInt(request.getParameter("endAtIndex")); if (endAtIndex > hdfsStores.size()) { endAtIndex = hdfsStores.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = hdfsStores.subList(startAtIndex, endAtIndex); model.addAttribute("hdfsstores", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/hdfsstores.jsp return "hdfsstores"; }
From source file:JDBCPool.dbcp.demo.sourcecode.PoolableConnectionFactory.java
/** * ?Connection?SQL//from w w w . j ava 2s . c o m * @param conn * @throws SQLException */ protected void initializeConnection(Connection conn) throws SQLException { Collection<String> sqls = _connectionInitSqls; if (conn.isClosed()) { throw new SQLException("initializeConnection: connection closed"); } if (null != sqls) { try (Statement stmt = conn.createStatement();) { for (String sql : sqls) { if (sql == null) { throw new NullPointerException("null connectionInitSqls element"); } stmt.execute(sql); } } } }