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.CreateTypeController.java
@RequestMapping(value = "/createtype", method = RequestMethod.GET) public String createType(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 {/*www . j av 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 create a new UDT (Type)"); model.addAttribute("typeAttribute", new Type()); // This will resolve to /WEB-INF/jsp/create-type.jsp return "create-type"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateSchemaController.java
@RequestMapping(value = "/createschema", method = RequestMethod.GET) public String createSchema(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 w w 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 create a new Schema"); model.addAttribute("schemaAttribute", new NewSchema()); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); // This will resolve to /WEB-INF/jsp/create-schema.jsp return "create-schema"; }
From source file:pivotal.au.se.gemfirexdweb.controller.AddLoaderController.java
@RequestMapping(value = "/addloader", method = RequestMethod.GET) public String createLoader(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 w ww. j a v a 2 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 add new Table Loader"); AddLoader loaderAttribute = new AddLoader(); if (request.getParameter("tableName") != null) { loaderAttribute.setTableName(request.getParameter("tableName")); } if (request.getParameter("schemaName") != null) { loaderAttribute.setSchemaName(request.getParameter("schemaName")); } model.addAttribute("loaderAttribute", loaderAttribute); // This will resolve to /WEB-INF/jsp/addloader.jsp return "addloader"; }
From source file:com.flexive.core.Database.java
/** * Helper function to close connections and statements. * A FxDbException is thrown if the close of the connection failed. * No Exception is thrown if the Statement failed to close, but a error is logged. * * @param caller a string representing the calling function/module, or null * @param con the connection to close, or null * @param stmt the statement to close, or null *//*from w w w . jav a 2 s . co m*/ public static void closeObjects(String caller, Connection con, Statement stmt) { try { if (stmt != null) stmt.close(); } catch (Exception exc) { //noinspection ThrowableInstanceNeverThrown StackTraceElement[] se = new Throwable().getStackTrace(); LOG.error(((caller != null) ? caller + " f" : "F") + "ailed to close the statement(s): " + exc.getMessage() + " Calling line: " + se[2].toString()); } if (con != null) { try { if (!con.isClosed()) { con.close(); } } catch (SQLException exc) { //noinspection ThrowableInstanceNeverThrown FxDbException dbExc = new FxDbException( ((caller != null) ? caller + " is u" : "U") + "nable to close the db connection"); LOG.error(dbExc); System.err.println(dbExc.getMessage()); } } }
From source file:pivotal.au.se.gemfirexdweb.controller.ReportsController.java
@RequestMapping(value = "/displayqueryreports", method = RequestMethod.GET) public String showQueryReports(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 av a 2 s .co 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 all query reports"); QueryBeanReader reader = QueryBeanReader.getInstance(); List<String> qlBeanNames = Arrays.asList(reader.getQueryListBeans()); List queries = new ArrayList(); List headerNames = new ArrayList(); int i = 0; for (String beanName : qlBeanNames) { i++; QueryList ql = reader.getQueryListBean(beanName); headerNames.add(ql.getDescription()); queries.add(ql.getQueryList()); } model.addAttribute("queries", queries); model.addAttribute("headerNames", headerNames); // This will resolve to /WEB-INF/jsp/reports.jsp return "reports"; }
From source file:com.flexoodb.pool.ConnectionPool.java
private Object getConnection(int counter) throws Exception { Connection con = null; try {// w w w . j av a 2 s . c o m con = (Connection) connections.borrowObject(); if ((con == null || con.isClosed()) && counter <= 5) { reconnect(); Thread.sleep(500); con = (Connection) getConnection(++counter); } if (_autoreturn && con != null) { _borrowed.put(con, new Date()); } } catch (Exception e) { if (con == null && counter <= 5) { if (!_autoreturn) { Thread.sleep(500); } else { Thread.sleep(1000); } con = (Connection) getConnection(++counter); } if (counter > 5) { //_log.warn("ran out of DB connections. Maximum active:"+connections.getMaxActive() +", Currently active:"+connections.getNumActive()+", Idle:"+connections.getNumIdle()); } } return con; }
From source file:pivotal.au.se.gemfirexdweb.controller.AddWriterController.java
@RequestMapping(value = "/addwriter", method = RequestMethod.GET) public String createWriter(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 w w w .j a 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; } } } logger.debug("Received request to add new Table Writer"); AddWriter writerAttribute = new AddWriter(); if (request.getParameter("tableName") != null) { writerAttribute.setTableName(request.getParameter("tableName")); } if (request.getParameter("schemaName") != null) { writerAttribute.setSchemaName(request.getParameter("schemaName")); } model.addAttribute("writerAttribute", writerAttribute); // This will resolve to /WEB-INF/jsp/addwriter.jsp return "addwriter"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateDiskStoreController.java
@RequestMapping(value = "/creatediskstore", method = RequestMethod.GET) public String createDiskStore(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 w ww .ja v a 2 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 create a new Disk Store"); model.addAttribute("diskStoreAttribute", new NewDiskStore()); // This will resolve to /WEB-INF/jsp/create-hdfsstore.jsp return "create-diskstore"; }
From source file:uk.ac.ebi.fg.annotare2.autosubs.SubsTracking.java
public void releaseConnection(Connection connection) throws SubsTrackingException { try {/*from w w w .java2 s . c o m*/ if (null != connection && !connection.isClosed()) { connection.close(); } } catch (SQLException e) { throw new SubsTrackingException(e); } }
From source file:pivotal.au.se.gemfirexdweb.controller.AddListenerController.java
@RequestMapping(value = "/addlistener", method = RequestMethod.GET) public String createListener(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 w ww . j a va 2s . co 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 add new Table Listener"); AddListener listenerAttribute = new AddListener(); if (request.getParameter("tableName") != null) { listenerAttribute.setTableName(request.getParameter("tableName")); } if (request.getParameter("schemaName") != null) { listenerAttribute.setSchemaName(request.getParameter("schemaName")); } model.addAttribute("listenerAttribute", listenerAttribute); // This will resolve to /WEB-INF/jsp/addlistener.jsp return "addlistener"; }