List of usage examples for java.sql SQLException printStackTrace
public void printStackTrace()
From source file:com.twitter.hdfsdu.TreeSizeByPathServlet.java
@Override public Iterable<String> getLines(HttpServletRequest request) { String paramPath = request.getParameter("path"); if (paramPath == null) { paramPath = "/"; }//from w w w . j a v a 2 s .c om List<String> lines = Lists.newLinkedList(); List<NodeData> elems = Lists.newArrayList(); Integer paramDepth = request.getParameter("depth") == null ? 2 : Integer.parseInt(request.getParameter("depth")); try { ResultSet resultSet = getSizeByPath(request); NodeData data; while (resultSet.next()) { data = new NodeData(); data.fileSize = resultSet.getString("size_in_bytes"); data.nChildren = resultSet.getLong("file_count"); data.path = resultSet.getString("path"); data.leaf = resultSet.getBoolean("leaf"); elems.add(data); } JSONObject jsonObject = DataTransformer.getJSONTree(paramPath, paramDepth, elems); String ans = null; if (jsonObject != null) { ans = jsonObject.toJSONString(); } if (ans == null) { lines.add("{ \"children\": [] }"); } else { lines.add(ans); } } catch (SQLException e) { e.printStackTrace(); } return lines; }
From source file:org.beangle.ems.avatar.service.DataBaseAvatarBase.java
protected byte[] getBytes(String name) { SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql, name); Blob obj = null;/*from www .j av a 2 s . c o m*/ if (rowSet.next()) { obj = (Blob) rowSet.getObject(1); try { return obj.getBytes(1L, (int) obj.length()); } catch (SQLException e) { e.printStackTrace(); return null; } } else { return null; } }
From source file:org.fornax.cartridges.sculptor.framework.util.db.DbUnitConnection.java
public int countRows(String table) throws Exception { Connection con = null;/*ww w .j a v a 2 s. co m*/ Statement stmt = null; ResultSet rs = null; try { con = getConnection().getConnection(); stmt = con.createStatement(); rs = stmt.executeQuery("select count(*) as rowcount from " + table); rs.next(); int count = rs.getInt("rowcount"); return count; } catch (SQLException e) { e.printStackTrace(); throw e; } finally { close(con, stmt, rs); } }
From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.YearStatisticPanel.java
public YearStatisticPanel() { setName("Jahr"); setLayout(new BorderLayout()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); HashMap<Integer, Integer> alarmCount = new HashMap<>(); try {//from w w w.j ava 2s. c o m ResultSet resultSet = Starter.getDatabase().getStatement().executeQuery( "SELECT STARTDATE_YEAR, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY STARTDATE_YEAR" + " ORDER BY STARTDATE_YEAR ASC"); while (resultSet.next()) { alarmCount.put(resultSet.getInt("STARTDATE_YEAR"), resultSet.getInt("COUNT")); } } catch (SQLException e) { e.printStackTrace(); } Set<Integer> years = alarmCount.keySet(); for (Integer year : years) { Integer count = alarmCount.get(year); dataset.addValue(count, count, year); } JFreeChart chart = ChartFactory.createBarChart3D("Jahresbersicht", "Jahr", "Einstze", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(getBackground()); ChartPanel panel = new ChartPanel(chart); panel.setPopupMenu(null); add(panel, BorderLayout.CENTER); }
From source file:com.student.manager.servlet.RegistrationServlet.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request/*from w w w . j a va 2s .c o m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String requestBody = IOUtils.toString(request.getReader()); String type = request.getParameter("type"); RegistrationActionController registrationActionController = new RegistrationActionController(); try { String responseMessage = registrationActionController.actionController(type, requestBody); PrintWriter out = response.getWriter(); out.println(responseMessage); } catch (SQLException e) { e.printStackTrace(); } }
From source file:com.taobao.tanggong.H2ServerTest.java
@Test public void test() { H2Server h = (H2Server) this.appContext.getBean("h2Server"); DataSource dataSource = (DataSource) this.appContext.getBean("dataSource"); try {/*from w w w . j a v a 2s . c om*/ Assert.assertNotNull(dataSource.getConnection()); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { Thread.sleep(1000000l); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:be.fedict.eid.integration.setup.db.SetupDatabase.java
@BeforeSuite @Parameters("context") public void setupDatabase(String context) throws ClassNotFoundException, SQLException, IOException { try {//from ww w .ja va2 s. c om // Setup the database loadJdbcDriver(); // Get a connection Connection connection = openConnection(); // Execute the update try { Statement statement = connection.createStatement(); try { String sql = readSql(context); statement.execute(sql); } finally { statement.close(); } } finally { connection.close(); } } catch (SQLException e) { e.printStackTrace(); throw e; } }
From source file:controladores.EnfermoController.java
private Connection getConnection(ServletContext servlet) { if (this.cn == null) { DriverManagerDataSource dataSource; dataSource = (DriverManagerDataSource) this.getBean("xeBBDD", servlet); try {//from w w w . j a va 2 s. c o m this.cn = dataSource.getConnection(); } catch (SQLException ex) { ex.printStackTrace(); } } return this.cn; }
From source file:com.orientechnologies.orient.jdbc.spring.CorenetThread.java
public CorenetThread(ApplicationContext context) { DataSourceContextHolder.setContext("corenet"); RoutingDataSource ds = context.getBean(RoutingDataSource.class); try {// w ww .j ava 2 s . co m this.connection = ds.getConnection(); } catch (SQLException e) { e.printStackTrace(); Assert.fail(); } }
From source file:com.recomdata.grails.rositaui.utils.SignalService.java
public void sendConsole(Long stepId, String message) { try {/*from w w w . j a v a 2 s . c o m*/ consolePs.setLong(1, stepId); consolePs.setTimestamp(2, new Timestamp(new java.util.Date().getTime())); consolePs.setString(3, message); consolePs.execute(); } catch (SQLException e) { e.printStackTrace(); } }