本文整理汇总了Java中com.mysql.jdbc.profiler.ProfilerEventHandler.consumeEvent方法的典型用法代码示例。如果您正苦于以下问题:Java ProfilerEventHandler.consumeEvent方法的具体用法?Java ProfilerEventHandler.consumeEvent怎么用?Java ProfilerEventHandler.consumeEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mysql.jdbc.profiler.ProfilerEventHandler
的用法示例。
在下文中一共展示了ProfilerEventHandler.consumeEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import com.mysql.jdbc.profiler.ProfilerEventHandler; //导入方法依赖的package包/类
/**
* We're done.
*
* @throws SQLException
* if a database error occurs
*/
public void close() throws SQLException {
// Belt and suspenders here - if we don't have a reference to the connection it's more than likely dead/gone and we won't be able to consume rows anyway
Object mutex = this;
MySQLConnection conn = null;
if (this.owner != null) {
conn = this.owner.connection;
if (conn != null) {
mutex = conn.getConnectionMutex();
}
}
boolean hadMore = false;
int howMuchMore = 0;
synchronized (mutex) {
// drain the rest of the records.
while (next() != null) {
hadMore = true;
howMuchMore++;
if (howMuchMore % 100 == 0) {
Thread.yield();
}
}
if (conn != null) {
if (!conn.getClobberStreamingResults() && conn.getNetTimeoutForStreamingResults() > 0) {
String oldValue = conn.getServerVariable("net_write_timeout");
if (oldValue == null || oldValue.length() == 0) {
oldValue = "60"; // the current default
}
this.io.clearInputStream();
java.sql.Statement stmt = null;
try {
stmt = conn.createStatement();
((com.mysql.jdbc.StatementImpl) stmt).executeSimpleNonQuery(conn, "SET net_write_timeout=" + oldValue);
} finally {
if (stmt != null) {
stmt.close();
}
}
}
if (conn.getUseUsageAdvisor()) {
if (hadMore) {
ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(conn);
eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_WARN, "",
this.owner.owningStatement == null ? "N/A" : this.owner.owningStatement.currentCatalog, this.owner.connectionId,
this.owner.owningStatement == null ? -1 : this.owner.owningStatement.getId(), -1, System.currentTimeMillis(), 0,
Constants.MILLIS_I18N, null, null,
Messages.getString("RowDataDynamic.2") + howMuchMore + Messages.getString("RowDataDynamic.3")
+ Messages.getString("RowDataDynamic.4") + Messages.getString("RowDataDynamic.5")
+ Messages.getString("RowDataDynamic.6") + this.owner.pointOfOrigin));
}
}
}
}
this.metadata = null;
this.owner = null;
}
示例2: close
import com.mysql.jdbc.profiler.ProfilerEventHandler; //导入方法依赖的package包/类
/**
* We're done.
*
* @throws SQLException
* if a database error occurs
*/
public void close() throws SQLException {
// Belt and suspenders here - if we don't have a reference to the connection it's more than likely dead/gone and we won't be able to consume rows anyway
Object mutex = this;
MySQLConnection conn = null;
if (this.owner != null) {
conn = this.owner.connection;
if (conn != null) {
mutex = conn.getConnectionMutex();
}
}
boolean hadMore = false;
int howMuchMore = 0;
synchronized (mutex) {
// drain the rest of the records.
while (next() != null) {
hadMore = true;
howMuchMore++;
if (howMuchMore % 100 == 0) {
Thread.yield();
}
}
if (conn != null) {
if (!conn.getClobberStreamingResults() && conn.getNetTimeoutForStreamingResults() > 0) {
String oldValue = conn.getServerVariable("net_write_timeout");
if (oldValue == null || oldValue.length() == 0) {
oldValue = "60"; // the current default
}
this.io.clearInputStream();
java.sql.Statement stmt = null;
try {
stmt = conn.createStatement();
((com.mysql.jdbc.StatementImpl) stmt).executeSimpleNonQuery(conn, "SET net_write_timeout=" + oldValue);
} finally {
if (stmt != null) {
stmt.close();
}
}
}
if (conn.getUseUsageAdvisor()) {
if (hadMore) {
ProfilerEventHandler eventSink = ProfilerEventHandlerFactory.getInstance(conn);
eventSink.consumeEvent(new ProfilerEvent(ProfilerEvent.TYPE_WARN, "", this.owner.owningStatement == null ? "N/A"
: this.owner.owningStatement.currentCatalog, this.owner.connectionId, this.owner.owningStatement == null ? -1
: this.owner.owningStatement.getId(), -1, System.currentTimeMillis(), 0, Constants.MILLIS_I18N, null, null, Messages
.getString("RowDataDynamic.2")
+ howMuchMore
+ Messages.getString("RowDataDynamic.3")
+ Messages.getString("RowDataDynamic.4")
+ Messages.getString("RowDataDynamic.5") + Messages.getString("RowDataDynamic.6") + this.owner.pointOfOrigin));
}
}
}
}
this.metadata = null;
this.owner = null;
}