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.CreateSynonymController.java
@RequestMapping(value = "/createsynonym", 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 {/* w w w .jav 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 create a new synonym"); TableDAO tableDAO = GemFireXDWebDAOFactory.getTableDAO(); ViewDAO viewDAO = GemFireXDWebDAOFactory.getViewDAO(); List<View> views = viewDAO.retrieveViewList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key")); model.addAttribute("views", views); List<Table> tbls = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key"), "ORDINARY"); List<Table> tblsHDFS = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key"), "HDFS"); tbls.addAll(tblsHDFS); model.addAttribute("tables", tbls); model.addAttribute("synonymAttribute", new NewSynonym()); model.addAttribute("objectName", request.getParameter("objectName")); // This will resolve to /WEB-INF/jsp/create-synonym.jsp return "create-synonym"; }
From source file:pivotal.au.se.gemfirexdweb.controller.AddWriterController.java
@RequestMapping(value = "/addwriter", method = RequestMethod.POST) public String createWriterAction(@ModelAttribute("writerAttribute") AddWriter writerAttribute, 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 www . ja v a2 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 action an event for Table Writer"); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer addWriter = new StringBuffer(); addWriter.append("CALL SYS.ATTACH_WRITER ('" + writerAttribute.getSchemaName() + "', \n"); addWriter.append("'" + writerAttribute.getTableName() + "', \n"); addWriter.append("'" + writerAttribute.getFunctionString() + "', \n"); if (!checkIfParameterEmpty(request, "initInfoString")) { addWriter.append("'" + writerAttribute.getInitInfoString() + "', \n"); } else { addWriter.append("NULL, \n"); } if (!checkIfParameterEmpty(request, "serverGroups")) { addWriter.append("'" + writerAttribute.getServerGroups() + "')"); } else { addWriter.append("NULL), \n"); } if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating Table Writer as -> " + addWriter.toString()); result = GemFireXDWebDAOUtil.runStoredCommand(addWriter.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create Table Writer SQL as follows as -> " + addWriter.toString()); model.addAttribute("sql", addWriter.toString()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, writerAttribute.getTableName() + "-Writer")); ServletOutputStream out = response.getOutputStream(); out.println(addWriter.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/addwriter.jsp return "addwriter"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateSchemaController.java
@RequestMapping(value = "/createschema", method = RequestMethod.POST) public String createSchemaAction(@ModelAttribute("schemaAttribute") NewSchema schemaAttribute, 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 va 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 action an event for create Schema"); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); String schema = schemaAttribute.getSchemaName(); logger.debug("New Schema name = " + schema); // perform some action here with what we have String submit = request.getParameter("pSubmit"); if (submit != null) { // build create HDFS Store SQL StringBuffer createSchema = new StringBuffer(); createSchema.append("CREATE SCHEMA "); if (!checkIfParameterEmpty(request, "authorizationSchema")) { createSchema.append("AUTHORIZATION " + schemaAttribute.getAuthorizationSchema() + " \n"); } else { createSchema.append(schema + " \n"); } if (!checkIfParameterEmpty(request, "serverGroups")) { createSchema.append("DEFAULT SERVER GROUPS (" + schemaAttribute.getServerGroups() + ") \n"); } if (submit.equalsIgnoreCase("create")) { Result result = new Result(); logger.debug("Creating Schema as -> " + createSchema.toString()); result = GemFireXDWebDAOUtil.runCommand(createSchema.toString(), (String) session.getAttribute("user_key")); model.addAttribute("result", result); model.addAttribute("chosenSchema", schemaAttribute.getAuthorizationSchema()); } else if (submit.equalsIgnoreCase("Show SQL")) { logger.debug("Create Schema SQL as follows as -> " + createSchema.toString()); model.addAttribute("sql", createSchema.toString()); model.addAttribute("chosenSchema", schemaAttribute.getAuthorizationSchema()); } else if (submit.equalsIgnoreCase("Save to File")) { response.setContentType(SAVE_CONTENT_TYPE); response.setHeader("Content-Disposition", "attachment; filename=" + String.format(FILENAME, schemaAttribute.getSchemaName())); ServletOutputStream out = response.getOutputStream(); out.println(createSchema.toString()); out.close(); return null; } } // This will resolve to /WEB-INF/jsp/create-schema.jsp return "create-schema"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateTriggerController.java
@RequestMapping(value = "/createtrigger", method = RequestMethod.GET) public String createTrigger(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 va2 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 Trigger"); NewTrigger newTrigger = new NewTrigger(); if (request.getParameter("settablename") != null) { model.addAttribute("tableName", request.getParameter("settablename")); } model.addAttribute("triggerAttribute", newTrigger); TableDAO tableDAO = GemFireXDWebDAOFactory.getTableDAO(); List<Table> tables = tableDAO.retrieveTableList((String) session.getAttribute("schema"), null, (String) session.getAttribute("user_key"), "tables"); model.addAttribute("tables", tables); // This will resolve to /WEB-INF/jsp/create-trigger.jsp return "create-trigger"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateAsyncController.java
@RequestMapping(value = "/createasync", method = RequestMethod.GET) public String createAsync(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. 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 Async Event Listener"); DiskStoreDAO dsDAO = GemFireXDWebDAOFactory.getDiskStoreDAO(); List<DiskStore> dsks = dsDAO.retrieveDiskStoreForCreateList((String) session.getAttribute("user_key")); model.addAttribute("diskstores", dsks); model.addAttribute("asyncAttribute", new NewAsync()); // This will resolve to /WEB-INF/jsp/create-async.jsp return "create-async"; }
From source file:pivotal.au.se.gemfirexdweb.controller.ConstraintController.java
@RequestMapping(value = "/constraints", method = RequestMethod.POST) public String performConstraintAction(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { String schema = null;/* ww w . j av a 2s. c o m*/ Result result = new Result(); 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 perform an action on the constraints"); String selectedSchema = request.getParameter("selectedSchema"); logger.debug("selectedSchema = " + selectedSchema); if (selectedSchema != null) { schema = selectedSchema; } else { schema = (String) session.getAttribute("schema"); } logger.debug("schema = " + schema); ConstraintDAO conDAO = GemFireXDWebDAOFactory.getConstraintDAO(); List<Constraint> cons = null; cons = conDAO.retrieveConstraintList(schema, (String) request.getParameter("search"), (String) session.getAttribute("user_key")); model.addAttribute("search", (String) request.getParameter("search")); model.addAttribute("cons", cons); model.addAttribute("records", cons.size()); model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key"))); model.addAttribute("chosenSchema", schema); // This will resolve to /WEB-INF/jsp/constraints.jsp return "constraints"; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateHDFSStoreController.java
@RequestMapping(value = "/createhdfsstore", method = RequestMethod.GET) public String createHDFSStore(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 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 create a new HDFS Store"); model.addAttribute("hdfsStoreAttribute", new NewHDFSStore()); // This will resolve to /WEB-INF/jsp/create-hdfsstore.jsp return "create-hdfsstore"; }
From source file:org.wso2.carbon.dashboard.portal.core.datasource.DataBaseInitializer.java
/** * To get the database type used by the user * * @param conn Connection of the datasource * @return type of the database// w ww. ja va2 s .co m * @throws DashboardPortalException */ private String getDatabaseType(Connection conn) throws DashboardPortalException { String type = null; try { if (conn != null && (!conn.isClosed())) { DatabaseMetaData metaData = conn.getMetaData(); String databaseProductName = metaData.getDatabaseProductName(); if (databaseProductName.matches("(?i).*mysql.*")) { type = "mysql"; } else if (databaseProductName.matches("(?i).*oracle.*")) { type = "oracle"; } else if (databaseProductName.matches("(?i).*microsoft.*")) { type = "mssql"; } else if (databaseProductName.matches("(?i).*h2.*")) { type = "h2"; } else { String msg = "Unsupported database: " + databaseProductName + ". Database will not be created automatically by the WSO2 Dashboard Server. " + "Please create the database using appropriate database scripts for " + "the database."; throw new DashboardPortalException(msg, null); } } } catch (SQLException e) { throw new DashboardPortalException("Failed to create tables for dashboards database.", e); } return type; }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateGatewaySenderController.java
@RequestMapping(value = "/creategatewaysender", method = RequestMethod.GET) public String createGatewaySender(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 .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; } } } logger.debug("Received request to create a new Gateway Sender"); DiskStoreDAO dsDAO = GemFireXDWebDAOFactory.getDiskStoreDAO(); List<DiskStore> dsks = dsDAO.retrieveDiskStoreForCreateList((String) session.getAttribute("user_key")); model.addAttribute("diskstores", dsks); model.addAttribute("gatewaySenderAttribute", new NewGatewaySender()); // This will resolve to /WEB-INF/jsp/create-gatewaysender.jsp return "create-gatewaysender"; }
From source file:pivotal.au.se.gemfirexdweb.controller.JarController.java
@RequestMapping(value = "/jars", method = RequestMethod.POST) public String performJarAction(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 ava 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; } } } int startAtIndex = 0, endAtIndex = 0; Result result = new Result(); List<Jar> jars = null; logger.debug("Received request to perform an action on the jar list"); JarDAO jarDAO = GemFireXDWebDAOFactory.getJarStoreDAO(); if (request.getParameter("search") != null) { jars = jarDAO.retrieveJarList("", (String) request.getParameter("search"), (String) session.getAttribute("user_key")); model.addAttribute("search", (String) request.getParameter("search")); } model.addAttribute("records", jars.size()); model.addAttribute("estimatedrecords", jars.size()); UserPref userPref = (UserPref) session.getAttribute("prefs"); if (jars.size() <= userPref.getRecordsToDisplay()) { model.addAttribute("jars", jars); } 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 > jars.size()) { endAtIndex = jars.size(); } } else { endAtIndex = userPref.getRecordsToDisplay(); } List subList = jars.subList(startAtIndex, endAtIndex); model.addAttribute("jars", subList); } model.addAttribute("startAtIndex", startAtIndex); model.addAttribute("endAtIndex", endAtIndex); // This will resolve to /WEB-INF/jsp/jars.jsp return "jars"; }