List of usage examples for java.sql SQLException printStackTrace
public void printStackTrace()
From source file:org.owasp.webgoat.plugin.CrossSiteScriptingLesson6b.java
protected String getPassword() { String password = "dave"; try {/*from ww w . java 2 s . co m*/ Connection connection = DatabaseUtilities.getConnection(getWebSession()); String query = "SELECT password FROM user_system_data WHERE user_name = 'dave'"; try { Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet results = statement.executeQuery(query); if ((results != null) && (results.first() == true)) { password = results.getString("password"); } } catch (SQLException sqle) { sqle.printStackTrace(); // do nothing } } catch (Exception e) { e.printStackTrace(); // do nothing } return (password); }
From source file:com.recomdata.grails.rositaui.utils.SignalService.java
public void sendSignal(Long jobId, Integer workflowStep, boolean success, String message) { try {/*from w w w .j a v a 2s .co m*/ ps.setLong(1, jobId); ps.setLong(2, workflowStep); ps.setTimestamp(3, new Timestamp(new java.util.Date().getTime())); ps.setBoolean(4, true); ps.setBoolean(5, success); ps.setString(6, message); ps.execute(); } catch (SQLException e) { e.printStackTrace(); } }
From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.TypeStatisticsPanel.java
public TypeStatisticsPanel() { setName("EinsatzTyp"); setLayout(new BorderLayout()); DefaultPieDataset dataset = new DefaultPieDataset(); HashMap<String, Integer> alarmCount = new HashMap<>(); try {/*from www . j a v a2 s .c om*/ ResultSet resultSet = Starter.getDatabase().getStatement() .executeQuery("SELECT TYPE, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY TYPE"); while (resultSet.next()) { String type = resultSet.getString("TYPE"); if (type.isEmpty()) type = "unbekannt"; int count = resultSet.getInt("COUNT"); type += " (" + count + ")"; alarmCount.put(type, count); } } catch (SQLException e) { e.printStackTrace(); } for (String key : alarmCount.keySet()) { dataset.setValue(key, alarmCount.get(key)); } JFreeChart chart = ChartFactory.createPieChart3D("Einsatztypen", dataset, false, false, false); chart.setBackgroundPaint(getBackground()); ChartPanel panel = new ChartPanel(chart); panel.setPopupMenu(null); panel.setBackground(getBackground()); add(panel, BorderLayout.CENTER); }
From source file:com.orientechnologies.orient.jdbc.spring.IoTatWorkThread.java
public IoTatWorkThread(ApplicationContext context) { DataSourceContextHolder.setContext("iotatwork"); RoutingDataSource ds = context.getBean(RoutingDataSource.class); try {/*from w ww . j a v a2 s . c om*/ this.connection = ds.getConnection(); } catch (SQLException e) { e.printStackTrace(); Assert.fail(); } }
From source file:com.persistent.cloudninja.utils.ProvisionConnectionUtility.java
public void closeStatement(Statement statement) { if (statement != null) { try {//from w ww. j av a2 s. co m statement.close(); } catch (SQLException sqlException) { sqlException.printStackTrace(); } } }
From source file:com.persistent.cloudninja.utils.ProvisionConnectionUtility.java
public void closeConnection(Connection connection) { if (connection != null) { try {//from ww w .j a v a 2s . com connection.close(); } catch (SQLException sqlException) { sqlException.printStackTrace(); } } }
From source file:de.rbs90.fwdisp.settingsgui.gui.tabs.statistics.WeekDayStatisticsPanel.java
public WeekDayStatisticsPanel() { setName("Wochentag"); setLayout(new BorderLayout()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String weekDays[] = { "Mo", "Die", "Mi", "Do", "Fr", "Sa", "So" }; int alarmCount[] = new int[7]; try {/*from w w w . j a v a2 s. c o m*/ ResultSet resultSet = Starter.getDatabase().getStatement().executeQuery( "SELECT STARTDATE_WEEKDAY, COUNT(*) AS COUNT FROM ALARMHISTORY GROUP BY STARTDATE_WEEKDAY"); while (resultSet.next()) { alarmCount[resultSet.getInt("STARTDATE_WEEKDAY") - 1] = resultSet.getInt("COUNT"); } } catch (SQLException e) { e.printStackTrace(); } for (int i = 0; i < 7; i++) { String dayName; int dayNumber; if (i != 6) { dayNumber = i + 1; dayName = weekDays[i]; } else { dayName = weekDays[6]; //Sunday dayNumber = 0; } dataset.addValue(alarmCount[dayNumber], "", dayName); } JFreeChart chart = ChartFactory.createBarChart3D("Wochentagsbersicht", "Wochentag", "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:gan.ism.ws.DrmLicense.java
/** * UserID commodity_id ? ,?/*from w ww . j a v a 2s . co m*/ * ?? * {"result":0,"msg":??, order_id":1111, "expired_date":? 2012-12-27 12:59:59?,"playback_count":30 } * {"result":-1,"msg":???} */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String user_id = request.getParameter("user_id"); String commodity_id = request.getParameter("commodity_id"); int status = -1; String msg = "?"; Long order_id = null; mLogger.debug("select t.id as order_id from transaction t, cas_transaction cas_t where t.c_user_id =" + user_id + " and cas_t.commodity_id =" + commodity_id + " and t.id=cas_t.transaction_id and t.payment_state=1 "); Connection conn = MssqlDB.createConnection(); ResultSet rs = MssqlDB.getInstance().executeQuery(conn, str, new Object[] { user_id, commodity_id }); try { if (rs.next()) { order_id = rs.getLong("order_id"); status = 0; msg = ""; } rs.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } Map<String, Object> map = new HashMap<String, Object>(); map.put("result", status); map.put("msg", msg); if (status == 0) { map.put("order_id", order_id); map.put("expired_date", ""); //? map.put("playback_count", -1); //? } JSONObject jo = JSONObject.fromObject(map); response.setContentType("text/html; charset=UTF-8"); mLogger.debug("C?" + jo.toString()); response.getWriter().write(jo.toString()); }
From source file:ch.ethz.coss.nervous.pulse.sql.SqlConnection.java
public Connection getConnection() { try {/*w ww. j a va2 s .c om*/ return source.getConnection(); } catch (SQLException e) { e.printStackTrace(); Log.getInstance().append(Log.FLAG_ERROR, "Can't get a connection from the data source"); return null; } }
From source file:com.persistent.cloudninja.utils.ProvisionConnectionUtility.java
public Connection getConnection(String url, String db_name, String db_user, String db_user_pwd) { Connection connection = null; int index = url.indexOf("="); String connUrl = url.substring(0, index + 1) + db_name + ";"; try {/*from w w w . ja v a 2s . c o m*/ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); connection = DriverManager.getConnection(connUrl, db_user, db_user_pwd); } catch (InstantiationException instantiationException) { instantiationException.printStackTrace(); } catch (IllegalAccessException illegalAccessException) { illegalAccessException.printStackTrace(); } catch (ClassNotFoundException classNotFoundException) { classNotFoundException.printStackTrace(); } catch (SQLException sqlException) { sqlException.printStackTrace(); } return connection; }