本文整理了Java中java.sql.SQLException.printStackTrace()
方法的一些代码示例,展示了SQLException.printStackTrace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SQLException.printStackTrace()
方法的具体详情如下:
包路径:java.sql.SQLException
类名称:SQLException
方法名:printStackTrace
暂无
代码示例来源:origin: spotbugs/spotbugs
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();
}
}
}
}
代码示例来源:origin: spotbugs/spotbugs
@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;
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
/** 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);
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
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);
代码示例来源:origin: yu199195/Raincat
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;
}
}
代码示例来源:origin: spotbugs/spotbugs
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();
}
}
}
}
代码示例来源:origin: wildfly/wildfly
try(ResultSet resultSet=ps.executeQuery()) {
int index=1;
while(resultSet.next()) {
byte[] bytes=resultSet.getBytes(1);
try {
e.printStackTrace();
代码示例来源:origin: spotbugs/spotbugs
.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();
代码示例来源:origin: spotbugs/spotbugs
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();
}
}
}
}
代码示例来源:origin: baomidou/mybatis-plus
rs = metadata.getIndexInfo(dbName, dbName, tableName, false, true);
indexInfos = new ArrayList<>();
while (rs.next()) {
e.printStackTrace();
代码示例来源:origin: spotbugs/spotbugs
.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();
代码示例来源:origin: spotbugs/spotbugs
stmt = conn.prepareStatement(str);
stmt.setString(1, "");
rs = stmt.executeQuery();
se.printStackTrace();
} finally {
try {
se.printStackTrace();
se.printStackTrace();
se.printStackTrace();
代码示例来源:origin: kairosdb/kairosdb
/**
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);
}
代码示例来源:origin: spotbugs/spotbugs
.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();
代码示例来源:origin: apache/cloudstack
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);
}
}
代码示例来源:origin: kairosdb/kairosdb
/**
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);
}
代码示例来源:origin: baomidou/mybatis-plus
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();
代码示例来源:origin: wycm/zhihu-crawler
/**
* 清空表
* @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();
}
}
}
代码示例来源:origin: kairosdb/kairosdb
/**
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);
}
代码示例来源:origin: hibernate/hibernate-orm
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();
内容来源于网络,如有侵权,请联系作者删除!