List of usage examples for java.sql SQLException printStackTrace
public void printStackTrace()
From source file:egovframework.rte.fdl.logging.db.EgovJDBCAppender.java
/** * connection ? ?? override .//from ww w .ja v a 2 s . co m * * @param sql * - log4j.xml ? ? <param name="sql" .. ? * @exception SQLException */ @Override protected void execute(String sql) throws SQLException { Connection con = null; Statement stmt = null; try { con = getConnection(); // dataSource bean ? autoCommit false ? true con.setAutoCommit(true); stmt = con.createStatement(); stmt.executeUpdate(sql); } catch (SQLException e) { e.printStackTrace(); throw e; } finally { stmt.close(); closeConnection(con); } // LogFactory.getLog("sysoutLogger").debug("Execute: " + sql); }
From source file:jobimtext.thesaurus.distributional.DatabaseThesaurusDatastructure.java
public List<Order2> getExpansions(String key, double threshold) { try {//w w w .j ava2 s. c o m String sql = "SELECT word1, word2,count FROM " + tableOrder2 + " WHERE word1 = ? and count > ? ORDER BY count desc"; PreparedStatement ps = getDatabaseConnection().getConnection().prepareStatement(sql); ps.setString(1, key); ps.setDouble(2, threshold); return fillExpansions(ps); } catch (SQLException e) { e.printStackTrace(); return null; } }
From source file:jobimtext.thesaurus.distributional.DatabaseThesaurusDatastructure.java
public List<Order2> getExpansions(String key, int numberOfEntries) { try {/* w ww . j a va 2s. c o m*/ String sql = "SELECT word1, word2,count FROM " + tableOrder2 + " WHERE word1 = ? ORDER BY count desc LIMIT 0," + numberOfEntries; PreparedStatement ps = getDatabaseConnection().getConnection().prepareStatement(sql); ps.setString(1, key); return fillExpansions(ps); } catch (SQLException e) { e.printStackTrace(); return null; } }
From source file:com.its.web.services.LicensesService.java
public List<License> readAll() { try {//from w w w . j av a2 s .co m return database.getLicenseDao().queryForAll(); } catch (SQLException e) { e.printStackTrace(); return null; } }
From source file:com.its.web.services.LicensesService.java
public boolean remove(Long id) { try {//from w w w . j av a2 s. co m database.getLicenseDao().deleteIds(Arrays.asList(id)); return true; } catch (SQLException e) { e.printStackTrace(); return false; } }
From source file:jobimtext.thesaurus.distributional.DatabaseThesaurusDatastructure.java
public Long getValuesCount(String key) { Long count = 0L;/*from ww w. j a v a 2s .c o m*/ String sql = "SELECT count FROM " + tableValues + " WHERE feature = ?"; PreparedStatement ps; try { ps = getDatabaseConnection().getConnection().prepareStatement(sql); ps.setString(1, key); ResultSet set = ps.executeQuery(); if (set.next()) { count = set.getLong("count"); } ps.close(); } catch (SQLException e) { e.printStackTrace(); } return count; }
From source file:jobimtext.thesaurus.distributional.DatabaseThesaurusDatastructure.java
private List<Order1> fillKeyValuesScores(String sql, String key) { PreparedStatement ps;//from www .j a v a 2 s .c om List<Order1> list = new ArrayList<Order1>(); try { ps = getDatabaseConnection().getConnection().prepareStatement(sql); ps.setString(1, key); ResultSet set = ps.executeQuery(); while (set.next()) { list.add(new Order1(set.getString("feature"), set.getDouble("sig"))); } ps.close(); } catch (SQLException e) { e.printStackTrace(); } return list; }
From source file:edu.byu.wso2.helper.BYUEntityHelper.java
public BYUEntityEmail getBYUEntityEmailFromNetId(String netid) { Connection con = null;// w w w.j a v a2s . c o m Statement statement = null; ResultSet resultSet = null; BYUEntityEmail byuEntityEmail = new BYUEntityEmail(netid); try { con = ds.getConnection(); if (log.isDebugEnabled()) log.debug("connection acquired. creating statement and executing query"); statement = con.createStatement(); resultSet = statement.executeQuery( "select email_address_type, email_address from iam.email_address ea, iam.credential cred " + " where ea.byu_id = cred.byu_id" + " and cred.credential_type = 'NET_ID' " + " and cred.credential_id = '" + netid + "'"); while (resultSet.next()) { String emailAddressType = resultSet.getString("email_address_type"); String emailAddress = resultSet.getString("email_address"); byuEntityEmail.addEmail(emailAddressType, emailAddress); if (log.isDebugEnabled()) log.debug("netid - " + netid + " emailAddressType: " + emailAddressType + " emailAddress: " + emailAddress); } } catch (SQLException e) { e.printStackTrace(); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { /* ignored */ } } if (statement != null) { try { statement.close(); } catch (SQLException e) { /* ignored */ } } if (con != null) { try { con.close(); } catch (SQLException e) { /* ignored */ } } } return byuEntityEmail; }
From source file:jobimtext.thesaurus.distributional.DatabaseThesaurusDatastructure.java
public Double getKeyValuesScore(String key, String val) { double score = 0.0; String sql = "SELECT sig FROM " + tableOrder1 + " WHERE word = ? and feature = ?"; PreparedStatement ps;//from ww w . ja va 2 s.c om try { ps = getDatabaseConnection().getConnection().prepareStatement(sql); ps.setString(1, key); ps.setString(2, val); ResultSet set = ps.executeQuery(); if (set.next()) { score = set.getDouble("sig"); } ps.close(); } catch (SQLException e) { e.printStackTrace(); } return score; }
From source file:com.its.web.services.LicensesService.java
public List<License> findByLicenseTypeId(Long licenseTypeId) { Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put("license_type_id", licenseTypeId); try {/*from w ww . j a va 2 s. c o m*/ return database.getLicenseDao().queryForFieldValues(fieldValues); } catch (SQLException e) { e.printStackTrace(); return null; } }