本文整理匯總了Java中java.sql.Connection.clearWarnings方法的典型用法代碼示例。如果您正苦於以下問題:Java Connection.clearWarnings方法的具體用法?Java Connection.clearWarnings怎麽用?Java Connection.clearWarnings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.sql.Connection
的用法示例。
在下文中一共展示了Connection.clearWarnings方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getConnection
import java.sql.Connection; //導入方法依賴的package包/類
/**
* @return a Connection instance that can be used to connect to the
* given database, if a previously-opened connection is available in
* the cache. Returns null if none is available in the map.
*/
public synchronized Connection getConnection(String connectStr,
String username) throws SQLException {
CacheKey key = new CacheKey(connectStr, username);
Connection cached = connectionMap.get(key);
if (null != cached) {
connectionMap.remove(key);
if (cached.isReadOnly()) {
// Read-only mode? Don't want it.
cached.close();
}
if (cached.isClosed()) {
// This connection isn't usable.
return null;
}
cached.rollback(); // Reset any transaction state.
cached.clearWarnings();
LOG.debug("Got cached connection for " + key);
}
return cached;
}
示例2: initializes_lazy
import java.sql.Connection; //導入方法依賴的package包/類
@Test
public void initializes_lazy() throws SQLException {
final Connection proxy = subject.getConnection();
assertNotNull(proxy);
verify(factory, never()).get();
proxy.clearWarnings();
proxy.clearWarnings();
verify(factory).get();
}