本文整理匯總了Java中java.sql.Statement.isClosed方法的典型用法代碼示例。如果您正苦於以下問題:Java Statement.isClosed方法的具體用法?Java Statement.isClosed怎麽用?Java Statement.isClosed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.sql.Statement
的用法示例。
在下文中一共展示了Statement.isClosed方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: closeStatement
import java.sql.Statement; //導入方法依賴的package包/類
/**
* Closes JDBC statement and open ResultSet without throwing exception. If there is one it is just logged.
*/
public static void closeStatement(
Statement statement ) {
if (statement == null) {
return;
}
try {
boolean isClosed;
try {
isClosed = statement.isClosed();
} catch (AbstractMethodError err) {
isClosed = false; // no JavaSE 6-compatible driver
}
if (statement != null && !isClosed) {
statement.close();
}
} catch (SQLException e) {
log.error(getFullSqlException("Could not close SQL statement", e));
}
}
示例2: closeStatement
import java.sql.Statement; //導入方法依賴的package包/類
public static void closeStatement(Statement stmt){
try{
if(stmt != null && !stmt.isClosed()){
stmt.close();
}
}catch(Exception e){
//
}
}
示例3: closeStatement
import java.sql.Statement; //導入方法依賴的package包/類
public void closeStatement ( final Statement statement )
{
try
{
if ( statement == null || statement.isClosed () )
{
return;
}
statement.close ();
}
catch ( final SQLException e )
{
logger.debug ( "Exception on closing statement", e );
}
}
示例4: createTables
import java.sql.Statement; //導入方法依賴的package包/類
public void createTables() throws IOException, SQLException {
URL resource = Resources.getResource(SkyWarsReloaded.class, "/tables.sql");
String[] databaseStructure = Resources.toString(resource, Charsets.UTF_8).split(";");
if (databaseStructure.length == 0) {
return;
}
Statement statement = null;
try {
connection.setAutoCommit(false);
statement = connection.createStatement();
for (String query : databaseStructure) {
query = query.trim();
if (query.isEmpty()) {
continue;
}
statement.execute(query);
}
connection.commit();
} finally {
connection.setAutoCommit(true);
if (statement != null && !statement.isClosed()) {
statement.close();
}
}
}