Refine search
void f2(Connection conn, String query) throws SQLException { PreparedStatement preparedStmt = null; try { preparedStmt = conn.prepareStatement(query); } finally { if (preparedStmt != null) { try { preparedStmt.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
@DesireNoWarning("OBL_UNSATISFIED_OBLIGATION") public String foo(Connection conn, String sql, String id) { String status = null; PreparedStatement ps = null; try { ps = conn.prepareStatement(sql); ps.setString(1, id); ResultSet rs = ps.executeQuery(); if (rs.next()) { status = rs.getString(1); } } catch (Exception e) { e.printStackTrace(); } finally { if (ps != null) { try { ps.close(); } catch (SQLException ex) { ex.printStackTrace(); } } } return status; } }
/** Return rank of 1 gram in google ngeams if it is less than 20k. Otherwise -1. */ public static int get1GramRank(String str) { String query = null; try{ connect(); str = str.trim(); if(str.contains("'")){ str = StringUtils.escapeString(str, new char[]{'\''},'\''); } int ngram = str.split("\\s+").length; if(ngram > 1) return -1; String table = "googlengrams_1_ranked20k"; if(!existsTable(table)) return -1; String phrase = escapeString(str); query = "select rank from " + table + " where phrase='" + phrase+"';"; Statement stmt = connection.createStatement(); ResultSet result = stmt.executeQuery(query); if(result.next()){ return result.getInt("rank"); }else return -1; }catch(SQLException e){ log.info("Error getting count for " + str+ ". The query was " + query); e.printStackTrace(); throw new RuntimeException(e); } }
Statement stmt = connection.createStatement(); ResultSet result = stmt.executeQuery(query); if(result.next()){ return result.getLong("count"); }else }catch(SQLException e){ log.info("Error getting count for " + str+ ". The query was " + query); e.printStackTrace(); throw new RuntimeException(e);
private List<Map<String, Object>> executeQuery(final String sql, final Object... params) { List<Map<String, Object>> list = null; try { try (Connection connection = dataSource.getConnection(); PreparedStatement ps = connection.prepareStatement(sql)) { if (params != null) { for (int i = 0; i < params.length; i++) { ps.setObject(i + 1, params[i]); } } ResultSet rs = ps.executeQuery(); ResultSetMetaData md = rs.getMetaData(); int columnCount = md.getColumnCount(); list = new ArrayList<>(); while (rs.next()) { Map<String, Object> rowData = Maps.newHashMap(); for (int i = 1; i <= columnCount; i++) { rowData.put(md.getColumnName(i), rs.getObject(i)); } list.add(rowData); } } } catch (SQLException e) { e.printStackTrace(); LOGGER.error("executeQuery->" + e.getMessage()); } return list; } }
void f3(Connection conn, String query) throws SQLException { PreparedStatement preparedStmt = null; try { preparedStmt = conn.prepareStatement(query); } finally { if (preparedStmt == null) { try { preparedStmt.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
try(ResultSet resultSet=ps.executeQuery()) { int index=1; while(resultSet.next()) { byte[] bytes=resultSet.getBytes(1); try { e.printStackTrace();
.prepareStatement("SELECT count(1) from tab"); while (rs.next()) { System.out.println(rs.getString(1)); rs.close(); } catch (SQLException e) { e.printStackTrace(); pstmt.close(); } catch (SQLException e) { e.printStackTrace(); connection.close(); } catch (SQLException e) { e.printStackTrace();
void falseNegative(Connection conn, String query) throws SQLException { PreparedStatement preparedStmt = null; try { preparedStmt = conn.prepareStatement(query); } finally { if (null != preparedStmt) { try { preparedStmt.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
rs = metadata.getIndexInfo(dbName, dbName, tableName, false, true); indexInfos = new ArrayList<>(); while (rs.next()) { e.printStackTrace();
.prepareStatement("DELETE FROM edec_deklarationen_mgt where dko_spediteur_dekl_nr like ? and dko_spediteur_nr = ?"); statement.setString(1, spediDeklNr); statement.setString(2, spediNr); .prepareStatement("DELETE FROM edec_deklarationen WHERE dek_id IN (SELECT d.dek_id FROM edec_deklarationen d " + "INNER JOIN edec_dekl_kopf k ON d.dek_id = k.dko_dek_id WHERE k.dko_spediteur_dekl_nr like ? )"); statement.setString(1, spediDeklNr); rs = statement.executeQuery(); rs.next(); countAfter = rs.getInt("rowcount"); } finally { rs.close(); } catch (SQLException e) { e.printStackTrace(); statement.close(); } catch (SQLException e) { e.printStackTrace(); con.close(); } catch (SQLException e) { e.printStackTrace();
stmt = conn.prepareStatement(str); stmt.setString(1, ""); rs = stmt.executeQuery(); se.printStackTrace(); } finally { try { se.printStackTrace(); se.printStackTrace(); se.printStackTrace();
/** Returns the reults as an ArrayList of Record objects. The Result set is closed within this call */ public ArrayList<Tag> getArrayList() { ArrayList<Tag> results = new ArrayList<Tag>(); try { if (m_onFirstResult) results.add(factory.newTag(m_resultSet)); while (m_resultSet.next()) results.add(factory.newTag(m_resultSet)); } catch (java.sql.SQLException sqle) { sqle.printStackTrace(); throw new GenOrmException(sqle); } close(); return (results); }
.prepareStatement("DELETE FROM edec_deklarationen_mgt where dko_spediteur_dekl_nr like ? and dko_spediteur_nr = ?"); statement.setString(1, spediDeklNr); statement.setString(2, spediNr); .prepareStatement("DELETE FROM edec_deklarationen WHERE dek_id IN (SELECT d.dek_id FROM edec_deklarationen d " + "INNER JOIN edec_dekl_kopf k ON d.dek_id = k.dko_dek_id WHERE k.dko_spediteur_dekl_nr like ? )"); statement.setString(1, spediDeklNr); rs = statement.executeQuery(); rs.next(); countAfter = rs.getInt("rowcount"); } finally { rs.close(); } catch (SQLException e) { e.printStackTrace(); statement.close(); } catch (SQLException e) { e.printStackTrace(); con.close(); } catch (SQLException e) { e.printStackTrace();
private void removeBumPriorityColumn(final Connection conn) { try (PreparedStatement removeBumPriorityColumnPstmt = conn.prepareStatement("ALTER TABLE `cloud`.`domain_router` DROP COLUMN `is_priority_bumpup`");) { removeBumPriorityColumnPstmt.executeUpdate(); } catch (final SQLException e) { e.printStackTrace(); throw new CloudRuntimeException("Adding redundancy to vpc, networks and vpc_offerings failed", e); } }
/** Returns the reults as an ArrayList of Record objects. The Result set is closed within this call */ public ArrayList<ServiceIndex> getArrayList() { ArrayList<ServiceIndex> results = new ArrayList<ServiceIndex>(); try { if (m_onFirstResult) results.add(factory.newServiceIndex(m_resultSet)); while (m_resultSet.next()) results.add(factory.newServiceIndex(m_resultSet)); } catch (java.sql.SQLException sqle) { sqle.printStackTrace(); throw new GenOrmException(sqle); } close(); return (results); }
try (PreparedStatement preparedStatement = connection.prepareStatement(tablesSql); ResultSet results = preparedStatement.executeQuery()) { while (results.next()) { String tableName = results.getString(dbQuery.tableName()); if (StringUtils.isNotEmpty(tableName)) { e.printStackTrace();
/** * 清空表 * @param cn * @throws SQLException */ public synchronized static void deleteUrlTable(Connection cn){ String sql = "DELETE FROM url"; PreparedStatement pstmt = null; try { pstmt = cn.prepareStatement(sql); pstmt.executeUpdate(); pstmt.close(); logger.info("url表删除成功---"); } catch (SQLException e) { e.printStackTrace(); } } }
/** Returns the reults as an ArrayList of Record objects. The Result set is closed within this call */ public ArrayList<ServiceModification> getArrayList() { ArrayList<ServiceModification> results = new ArrayList<ServiceModification>(); try { if (m_onFirstResult) results.add(factory.newServiceModification(m_resultSet)); while (m_resultSet.next()) results.add(factory.newServiceModification(m_resultSet)); } catch (java.sql.SQLException sqle) { sqle.printStackTrace(); throw new GenOrmException(sqle); } close(); return (results); }
try { cn = getDataSource().getConnection(); pstmt = cn.prepareStatement( "select id, geom from geomtest where type = ? order by id" ); pstmt.setString( 1, type ); results = pstmt.executeQuery(); while ( results.next() ) { Integer id = results.getInt( 1 ); Object obj = results.getObject( 2 ); e.printStackTrace();