本文整理了Java中java.sql.SQLException.toString()
方法的一些代码示例,展示了SQLException.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SQLException.toString()
方法的具体详情如下:
包路径:java.sql.SQLException
类名称:SQLException
方法名:toString
暂无
代码示例来源:origin: apache/drill
/** Tests that basic case of trying to create a prepare statement with parameters. */
@Test( expected = SQLException.class )
public void testSqlQueryWithParamNotSupported() throws SQLException {
try {
connection.prepareStatement( "VALUES ?, ?" );
}
catch ( final SQLException e ) {
assertThat(
"Check whether params.-unsupported wording changed or checks changed.",
e.toString(), containsString("Illegal use of dynamic parameter") );
throw e;
}
}
代码示例来源:origin: quartz-scheduler/quartz
throw new JobPersistenceException(
"Failed to obtain DB connection from data source '"
+ getDataSource() + "': " + sqle.toString(), sqle);
} catch (Throwable e) {
throw new JobPersistenceException(
getLog().warn("Failed to override connection auto commit/transaction isolation.", sqle);
} catch (Throwable e) {
try { conn.close(); } catch(Throwable ignored) {}
代码示例来源:origin: apache/cloudstack
private void updatePrimaryStore(Connection conn) {
try(PreparedStatement sql = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type = 'Filesystem' or pool_type = 'LVM'");) {
sql.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
sql.setString(2, "HOST");
sql.executeUpdate();
try(PreparedStatement sql2 = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type != 'Filesystem' and pool_type != 'LVM'");) {
sql2.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
sql2.setString(2, "CLUSTER");
sql2.executeUpdate();
}catch (SQLException e) {
throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
}
} catch (SQLException e) {
throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
}
}
代码示例来源:origin: johnewart/gearman-java
if(conn != null)
st = conn.prepareStatement(findJobByHandleQuery);
st.setString(1, jobHandle);
LOG.debug(se.toString());
} catch (IOException e) {
e.printStackTrace();
st.close();
conn.close();
代码示例来源:origin: org.apache.isis.runtimes.dflt.objectstores/sql-impl
@Override
public int update(final String sql) {
LOG.debug("SQL: " + sql);
PreparedStatement statement;
try {
statement = connection.prepareStatement(sql);
addPreparedValues(statement);
final int updateCount = statement.executeUpdate();
statement.close();
return updateCount;
} catch (final SQLException e) {
LOG.error("failed to execute " + sql, e);
throw new SqlObjectStoreException("SQL error: " + e.toString(), e);
} finally {
clearPreparedValues();
}
}
代码示例来源:origin: com.tomitribe.tribestream/tribestream-container
@Override
public Check check() {
final List<String> details = new ArrayList<String>();
Connection c = null;
try {
details.add("Getting connection.");
c = dataSource.getConnection();
details.add("Creating statement.");
try (final PreparedStatement statement = c.prepareStatement(query)) {
statement.setQueryTimeout(timeout);
details.add("Executing statement.");
if (!statement.execute()) {
return new Check(name, "validation query didn't execute correctly for " + name, Status.DOWN, details);
}
return new Check(name, "validation query executed correctly for " + name, Status.UP, details);
}
} catch (final SQLException e) {
return new Check(name, e.toString(), Status.DOWN, details);
} finally {
try {
if (c != null) {
c.close();
}
} catch (final Exception e) {
// no-op
}
}
}
代码示例来源:origin: com.att.research.xacml/xacml
try {
if (connection != null) {
connection.close();
resultSet = preparedStatement.executeQuery();
} catch (SQLException ex) {
this.logger.error("SQLException executing query: " + ex.toString(), ex);
preparedStatement.close();
} catch (SQLException e) {
this.logger.error("SQLException closing preparedStatment: " + e.toString(), e);
connection.close();
this.logger.error("SQLException decoding results: " + ex.toString());
resultSet.close();
} catch (SQLException e) {
this.logger.error("SQLException closing resultSet: " + e.toString() + " (May be memory leak)");
preparedStatement.close();
} catch (SQLException e) {
this.logger.error("SQLException closing preparedStatement: " + e.toString() + " (May be memory leak)");
connection.close();
} catch (SQLException e) {
this.logger.error("SQLException closing connection: " + e.toString() + " (May be memory leak)");
代码示例来源:origin: crazyacking/zeekEye
if (rs.next()) {
weiboID = rs.getString("weiboID");
ps = conn.prepareStatement("UPDATE weibo SET isCommentFetched = 1 WHERE weiboID = ?");
ps.setString(1, weiboID);
ps.execute();
ps.close();
conn.rollback();
} catch (SQLException e1) {
logger.error(e1.toString());
conn.close();
} catch (SQLException e) {
logger.error("", e);
代码示例来源:origin: quartz-scheduler/quartz
throw new JobPersistenceException(
"Failed to obtain DB connection from data source '"
+ getDataSource() + "': " + sqle.toString(), sqle);
} catch (Throwable e) {
throw new JobPersistenceException(
getLog().warn("Failed to override connection auto commit/transaction isolation.", sqle);
} catch (Throwable e) {
try { conn.close(); } catch(Throwable ignored) {}
代码示例来源:origin: GoSimpleLLC/jpgAgent
public static void finishLog(final int job_log_id, final JobStatus job_status)
{
final String log_sql = Config.INSTANCE.sql.getProperty("sql.joblog.finish_log");
try (final PreparedStatement log_statement = Database.INSTANCE.getMainConnection().prepareStatement(log_sql))
{
log_statement.setString(1, job_status.getDbRepresentation());
log_statement.setInt(2, job_log_id);
log_statement.execute();
}
catch (SQLException e)
{
Config.INSTANCE.logger.error("Could not save job log to database.");
Config.INSTANCE.logger.error("Exception: " + e.toString());
Config.INSTANCE.logger.error("Message: " + e.getMessage());
}
}
}
代码示例来源:origin: org.codehaus.castor/castor-jdo
/**
* {@inheritDoc}
*/
public Object generateKey(final Connection conn, final String tableName,
final String primKeyName) throws PersistenceException {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
// prepares the statement
String sql = _factory.getIdentitySelectString(tableName, primKeyName);
stmt = conn.prepareStatement(sql);
// execute the prepared statement
rs = stmt.executeQuery();
// process result set using appropriate handler and return its value
return _typeHandler.getValue(rs);
} catch (SQLException e) {
LOG.error("Problem generating new key", e);
String msg = Messages.format("persist.keyGenSQL",
this.getClass().getName(), e.toString());
throw new PersistenceException(msg);
} finally {
try {
if (rs != null) { rs.close(); }
if (stmt != null) { stmt.close(); }
} catch (SQLException e) {
LOG.warn("Problem closing JDBC statement", e);
}
}
}
代码示例来源:origin: MissionCriticalCloud/cosmic
protected String testValidity(final String name, final Connection conn) {
if (conn != null) {
synchronized (conn) {
try (PreparedStatement pstmt = conn.prepareStatement("SELECT 1")) {
pstmt.executeQuery();
} catch (final SQLException e) {
s_logger.error("Unable to keep the db connection for " + name, e);
return e.toString();
}
}
}
return null;
}
代码示例来源:origin: att/XACML
try {
if (connection != null) {
connection.close();
resultSet = preparedStatement.executeQuery();
} catch (SQLException ex) {
this.logger.error("SQLException executing query: " + ex.toString(), ex);
preparedStatement.close();
} catch (SQLException e) {
this.logger.error("SQLException closing preparedStatment: " + e.toString(), e);
connection.close();
this.logger.error("SQLException decoding results: " + ex.toString());
resultSet.close();
} catch (SQLException e) {
this.logger.error("SQLException closing resultSet: " + e.toString() + " (May be memory leak)");
preparedStatement.close();
} catch (SQLException e) {
this.logger.error("SQLException closing preparedStatement: " + e.toString() + " (May be memory leak)");
connection.close();
} catch (SQLException e) {
this.logger.error("SQLException closing connection: " + e.toString() + " (May be memory leak)");
代码示例来源:origin: johnewart/gearman-java
if (conn != null) {
st = conn.prepareStatement(countQuery);
rs = st.executeQuery();
LOG.debug(se.toString());
return -1;
} finally {
st.close();
conn.close();
代码示例来源:origin: quartz-scheduler/quartz
"Failed to obtain DB connection from data source '"
+ getNonManagedTXDataSource() + "': "
+ sqle.toString(), sqle);
} catch (Throwable e) {
throw new JobPersistenceException(
getLog().warn("Failed to override connection auto commit/transaction isolation.", sqle);
} catch (Throwable e) {
try { conn.close(); } catch(Throwable tt) {}
代码示例来源:origin: GoSimpleLLC/jpgAgent
public static void finishLog(final int job_step_log_id, final StepStatus step_status, final int step_result, final String step_output)
{
final String log_sql = Config.INSTANCE.sql.getProperty("sql.jobsteplog.finish_log");
try (PreparedStatement update_log_statement = Database.INSTANCE.getMainConnection().prepareStatement(log_sql))
{
update_log_statement.setString(1, step_status.getDbRepresentation());
update_log_statement.setInt(2, step_result);
update_log_statement.setString(3, step_output);
update_log_statement.setInt(4, job_step_log_id);
update_log_statement.execute();
}
catch (final SQLException e)
{
Config.INSTANCE.logger.error("Could not save job step log to database.");
Config.INSTANCE.logger.error("Exception: " + e.toString());
Config.INSTANCE.logger.error("Message: " + e.getMessage());
}
}
}
代码示例来源:origin: BriData/DBus
String query = getTotalRowsCountQuery(table, splitCol, tablePartition);
conn = getConnection();
pStmt = conn.prepareStatement(query, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
results = pStmt.executeQuery();
if (results.next()) {
results.close();
if (pStmt != null)
pStmt.close();
LoggingUtils.logAll(LOG, "SQLException happend on closing resource: " + sqlE.toString(), sqlE);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
代码示例来源:origin: GoSimpleLLC/jpgAgent
private void clearJobAgent()
{
final String update_job_sql = Config.INSTANCE.sql.getProperty("sql.job.clear_job_agent");
try (final PreparedStatement update_job_statement = Database.INSTANCE.getMainConnection().prepareStatement(update_job_sql))
{
update_job_statement.setInt(1, job_id);
update_job_statement.execute();
}
catch (SQLException e)
{
Config.INSTANCE.logger.error("There was an error clearing the job agent from the job.");
Config.INSTANCE.logger.error("Exception: " + e.toString());
Config.INSTANCE.logger.error("Message: " + e.getMessage());
}
}
代码示例来源:origin: johnewart/gearman-java
st = conn.prepareStatement(fetchJobHandlesQuery);
rs = st.executeQuery();
LOG.debug(se.toString());
} finally {
try {
st.close();
conn.close();
代码示例来源:origin: quartz-scheduler/quartz
"Failed to obtain DB connection from data source '"
+ getNonManagedTXDataSource() + "': "
+ sqle.toString(), sqle);
} catch (Throwable e) {
throw new JobPersistenceException(
getLog().warn("Failed to override connection auto commit/transaction isolation.", sqle);
} catch (Throwable e) {
try { conn.close(); } catch(Throwable tt) {}
内容来源于网络,如有侵权,请联系作者删除!