Skip to content

Commit

Permalink
rename getNextId to getNextTraceId
Browse files Browse the repository at this point in the history
  • Loading branch information
codefollower committed Mar 19, 2016
1 parent 47eba42 commit c488c01
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 41 deletions.
Expand Up @@ -61,15 +61,13 @@
* @author H2 Group
* @author zhh
*/
// 只支持Java 1.7中的JDBC API
public class JdbcConnection extends TraceObject implements Connection {

private static boolean keepOpenStackTrace;
private final String url;
private final String user;

// ResultSet.HOLD_CURSORS_OVER_COMMIT
private int holdability = 1;
private int holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;

private Session session;
private Command commit, rollback;
Expand Down Expand Up @@ -100,7 +98,7 @@ public JdbcConnection(String url, Properties info) throws SQLException {
// this will return an embedded or server connection
session = new ClientSession(ci).connectEmbeddedOrServer();
trace = session.getTrace();
int id = getNextId(TraceObject.CONNECTION);
int id = getNextTraceId(TraceObject.CONNECTION);
setTrace(trace, TraceObject.CONNECTION, id);
user = ci.getUserName();
url = ci.getURL(); // 不含参数
Expand All @@ -123,7 +121,7 @@ public JdbcConnection(String url, Properties info) throws SQLException {
public JdbcConnection(Session session, String user, String url) {
this.session = session;
trace = session.getTrace();
int id = getNextId(TraceObject.CONNECTION);
int id = getNextTraceId(TraceObject.CONNECTION);
setTrace(trace, TraceObject.CONNECTION, id);
this.user = user;
this.url = url;
Expand Down Expand Up @@ -159,7 +157,7 @@ private void closeOld() {
@Override
public Statement createStatement() throws SQLException {
try {
int id = getNextId(TraceObject.STATEMENT);
int id = getNextTraceId(TraceObject.STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("Statement", TraceObject.STATEMENT, id, "createStatement()");
}
Expand All @@ -184,7 +182,7 @@ public Statement createStatement() throws SQLException {
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
try {
int id = getNextId(TraceObject.STATEMENT);
int id = getNextTraceId(TraceObject.STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("Statement", TraceObject.STATEMENT, id, "createStatement(" + resultSetType + ", "
+ resultSetConcurrency + ")");
Expand Down Expand Up @@ -212,7 +210,7 @@ public Statement createStatement(int resultSetType, int resultSetConcurrency) th
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
throws SQLException {
try {
int id = getNextId(TraceObject.STATEMENT);
int id = getNextTraceId(TraceObject.STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("Statement", TraceObject.STATEMENT, id, "createStatement(" + resultSetType + ", "
+ resultSetConcurrency + ", " + resultSetHoldability + ")");
Expand All @@ -236,7 +234,7 @@ public Statement createStatement(int resultSetType, int resultSetConcurrency, in
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException {
try {
int id = getNextId(TraceObject.PREPARED_STATEMENT);
int id = getNextTraceId(TraceObject.PREPARED_STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement("
+ quote(sql) + ")");
Expand All @@ -259,7 +257,7 @@ public PreparedStatement prepareStatement(String sql) throws SQLException {
*/
PreparedStatement prepareAutoCloseStatement(String sql) throws SQLException {
try {
int id = getNextId(TraceObject.PREPARED_STATEMENT);
int id = getNextTraceId(TraceObject.PREPARED_STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement("
+ quote(sql) + ")");
Expand All @@ -282,7 +280,7 @@ PreparedStatement prepareAutoCloseStatement(String sql) throws SQLException {
@Override
public DatabaseMetaData getMetaData() throws SQLException {
try {
int id = getNextId(TraceObject.DATABASE_META_DATA);
int id = getNextTraceId(TraceObject.DATABASE_META_DATA);
if (isDebugEnabled()) {
debugCodeAssign("DatabaseMetaData", TraceObject.DATABASE_META_DATA, id, "getMetaData()");
}
Expand Down Expand Up @@ -591,7 +589,7 @@ public void clearWarnings() throws SQLException {
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
try {
int id = getNextId(TraceObject.PREPARED_STATEMENT);
int id = getNextTraceId(TraceObject.PREPARED_STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement("
+ quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ")");
Expand Down Expand Up @@ -819,7 +817,7 @@ public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
@Override
public CallableStatement prepareCall(String sql) throws SQLException {
try {
int id = getNextId(TraceObject.CALLABLE_STATEMENT);
int id = getNextTraceId(TraceObject.CALLABLE_STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, "prepareCall(" + quote(sql)
+ ")");
Expand Down Expand Up @@ -848,7 +846,7 @@ public CallableStatement prepareCall(String sql) throws SQLException {
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
try {
int id = getNextId(TraceObject.CALLABLE_STATEMENT);
int id = getNextTraceId(TraceObject.CALLABLE_STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, "prepareCall(" + quote(sql)
+ ", " + resultSetType + ", " + resultSetConcurrency + ")");
Expand Down Expand Up @@ -879,7 +877,7 @@ public CallableStatement prepareCall(String sql, int resultSetType, int resultSe
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
try {
int id = getNextId(TraceObject.CALLABLE_STATEMENT);
int id = getNextTraceId(TraceObject.CALLABLE_STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("CallableStatement", TraceObject.CALLABLE_STATEMENT, id, "prepareCall(" + quote(sql)
+ ", " + resultSetType + ", " + resultSetConcurrency + ", " + resultSetHoldability + ")");
Expand All @@ -902,7 +900,7 @@ public CallableStatement prepareCall(String sql, int resultSetType, int resultSe
@Override
public Savepoint setSavepoint() throws SQLException {
try {
int id = getNextId(TraceObject.SAVEPOINT);
int id = getNextTraceId(TraceObject.SAVEPOINT);
if (isDebugEnabled()) {
debugCodeAssign("Savepoint", TraceObject.SAVEPOINT, id, "setSavepoint()");
}
Expand All @@ -926,7 +924,7 @@ public Savepoint setSavepoint() throws SQLException {
@Override
public Savepoint setSavepoint(String name) throws SQLException {
try {
int id = getNextId(TraceObject.SAVEPOINT);
int id = getNextTraceId(TraceObject.SAVEPOINT);
if (isDebugEnabled()) {
debugCodeAssign("Savepoint", TraceObject.SAVEPOINT, id, "setSavepoint(" + quote(name) + ")");
}
Expand Down Expand Up @@ -996,7 +994,7 @@ private static JdbcSavepoint convertSavepoint(Savepoint savepoint) {
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
try {
int id = getNextId(TraceObject.PREPARED_STATEMENT);
int id = getNextTraceId(TraceObject.PREPARED_STATEMENT);
if (isDebugEnabled()) {
debugCodeAssign("PreparedStatement", TraceObject.PREPARED_STATEMENT, id, "prepareStatement("
+ quote(sql) + ", " + resultSetType + ", " + resultSetConcurrency + ", " + resultSetHoldability
Expand Down Expand Up @@ -1399,7 +1397,7 @@ ResultSet getGeneratedKeys(JdbcStatement stat, int id) {
@Override
public Clob createClob() throws SQLException {
try {
int id = getNextId(TraceObject.CLOB);
int id = getNextTraceId(TraceObject.CLOB);
debugCodeAssign("Clob", TraceObject.CLOB, id, "createClob()");
checkClosed();
Value v = session.getDataHandler().getLobStorage()
Expand All @@ -1418,7 +1416,7 @@ public Clob createClob() throws SQLException {
@Override
public Blob createBlob() throws SQLException {
try {
int id = getNextId(TraceObject.BLOB);
int id = getNextTraceId(TraceObject.BLOB);
debugCodeAssign("Blob", TraceObject.BLOB, id, "createClob()");
checkClosed();
Value v = session.getDataHandler().getLobStorage()
Expand All @@ -1438,7 +1436,7 @@ public Blob createBlob() throws SQLException {
@Override
public NClob createNClob() throws SQLException {
try {
int id = getNextId(TraceObject.CLOB);
int id = getNextTraceId(TraceObject.CLOB);
debugCodeAssign("NClob", TraceObject.CLOB, id, "createNClob()");
checkClosed();
Value v = session.getDataHandler().getLobStorage()
Expand Down Expand Up @@ -1621,12 +1619,12 @@ Object convertToDefaultObject(Value v) {
Object o;
switch (v.getType()) {
case Value.CLOB: {
int id = getNextId(TraceObject.CLOB);
int id = getNextTraceId(TraceObject.CLOB);
o = new JdbcClob(this, v, id);
break;
}
case Value.BLOB: {
int id = getNextId(TraceObject.BLOB);
int id = getNextTraceId(TraceObject.BLOB);
o = new JdbcBlob(this, v, id);
break;
}
Expand Down
Expand Up @@ -77,7 +77,7 @@ public class JdbcDataSource extends TraceObject implements DataSource, Serializa
*/
public JdbcDataSource() {
initFactory();
int id = getNextId(TraceObject.DATA_SOURCE);
int id = getNextTraceId(TraceObject.DATA_SOURCE);
setTrace(factory.getTrace(), TraceObject.DATA_SOURCE, id);
}

Expand Down
Expand Up @@ -93,7 +93,7 @@ void setCachedColumnLabelMap(HashMap<String, Integer> cachedColumnLabelMap) {
@Override
public ResultSet executeQuery() throws SQLException {
try {
int id = getNextId(TraceObject.RESULT_SET);
int id = getNextTraceId(TraceObject.RESULT_SET);
if (isDebugEnabled()) {
debugCodeAssign("ResultSet", TraceObject.RESULT_SET, id, "executeQuery()");
}
Expand Down Expand Up @@ -166,7 +166,7 @@ private int executeUpdateInternal() throws SQLException {
@Override
public boolean execute() throws SQLException {
try {
int id = getNextId(TraceObject.RESULT_SET);
int id = getNextTraceId(TraceObject.RESULT_SET);
if (isDebugEnabled()) {
debugCodeCall("execute");
}
Expand Down Expand Up @@ -1037,7 +1037,7 @@ public ResultSetMetaData getMetaData() throws SQLException {
if (result == null) {
return null;
}
int id = getNextId(TraceObject.RESULT_SET_META_DATA);
int id = getNextTraceId(TraceObject.RESULT_SET_META_DATA);
if (isDebugEnabled()) {
debugCodeAssign("ResultSetMetaData", TraceObject.RESULT_SET_META_DATA, id, "getMetaData()");
}
Expand Down Expand Up @@ -1277,7 +1277,7 @@ public boolean execute(String sql, String[] columnNames) throws SQLException {
@Override
public ParameterMetaData getParameterMetaData() throws SQLException {
try {
int id = getNextId(TraceObject.PARAMETER_META_DATA);
int id = getNextTraceId(TraceObject.PARAMETER_META_DATA);
if (isDebugEnabled()) {
debugCodeAssign("ParameterMetaData", TraceObject.PARAMETER_META_DATA, id, "getParameterMetaData()");
}
Expand Down
Expand Up @@ -134,7 +134,7 @@ public boolean next() throws SQLException {
@Override
public ResultSetMetaData getMetaData() throws SQLException {
try {
int id = getNextId(TraceObject.RESULT_SET_META_DATA);
int id = getNextTraceId(TraceObject.RESULT_SET_META_DATA);
if (isDebugEnabled()) {
debugCodeAssign("ResultSetMetaData", TraceObject.RESULT_SET_META_DATA, id, "getMetaData()");
}
Expand Down Expand Up @@ -991,7 +991,7 @@ public Timestamp getTimestamp(String columnLabel, Calendar calendar) throws SQLE
@Override
public Blob getBlob(int columnIndex) throws SQLException {
try {
int id = getNextId(TraceObject.BLOB);
int id = getNextTraceId(TraceObject.BLOB);
debugCodeAssign("Blob", TraceObject.BLOB, id, "getBlob(" + columnIndex + ")");
Value v = get(columnIndex);
return v == ValueNull.INSTANCE ? null : new JdbcBlob(conn, v, id);
Expand All @@ -1011,7 +1011,7 @@ public Blob getBlob(int columnIndex) throws SQLException {
@Override
public Blob getBlob(String columnLabel) throws SQLException {
try {
int id = getNextId(TraceObject.BLOB);
int id = getNextTraceId(TraceObject.BLOB);
debugCodeAssign("Blob", TraceObject.BLOB, id, "getBlob(" + quote(columnLabel) + ")");
Value v = get(columnLabel);
return v == ValueNull.INSTANCE ? null : new JdbcBlob(conn, v, id);
Expand Down Expand Up @@ -1103,7 +1103,7 @@ public InputStream getBinaryStream(String columnLabel) throws SQLException {
@Override
public Clob getClob(int columnIndex) throws SQLException {
try {
int id = getNextId(TraceObject.CLOB);
int id = getNextTraceId(TraceObject.CLOB);
debugCodeAssign("Clob", TraceObject.CLOB, id, "getClob(" + columnIndex + ")");
Value v = get(columnIndex);
return v == ValueNull.INSTANCE ? null : new JdbcClob(conn, v, id);
Expand All @@ -1123,7 +1123,7 @@ public Clob getClob(int columnIndex) throws SQLException {
@Override
public Clob getClob(String columnLabel) throws SQLException {
try {
int id = getNextId(TraceObject.CLOB);
int id = getNextTraceId(TraceObject.CLOB);
debugCodeAssign("Clob", TraceObject.CLOB, id, "getClob(" + quote(columnLabel) + ")");
Value v = get(columnLabel);
return v == ValueNull.INSTANCE ? null : new JdbcClob(conn, v, id);
Expand All @@ -1143,7 +1143,7 @@ public Clob getClob(String columnLabel) throws SQLException {
@Override
public Array getArray(int columnIndex) throws SQLException {
try {
int id = getNextId(TraceObject.ARRAY);
int id = getNextTraceId(TraceObject.ARRAY);
debugCodeAssign("Clob", TraceObject.ARRAY, id, "getArray(" + columnIndex + ")");
Value v = get(columnIndex);
return v == ValueNull.INSTANCE ? null : new JdbcArray(conn, v, id);
Expand All @@ -1163,7 +1163,7 @@ public Array getArray(int columnIndex) throws SQLException {
@Override
public Array getArray(String columnLabel) throws SQLException {
try {
int id = getNextId(TraceObject.ARRAY);
int id = getNextTraceId(TraceObject.ARRAY);
debugCodeAssign("Clob", TraceObject.ARRAY, id, "getArray(" + quote(columnLabel) + ")");
Value v = get(columnLabel);
return v == ValueNull.INSTANCE ? null : new JdbcArray(conn, v, id);
Expand Down Expand Up @@ -3370,7 +3370,7 @@ public void updateNClob(String columnLabel, NClob x) throws SQLException {
@Override
public NClob getNClob(int columnIndex) throws SQLException {
try {
int id = getNextId(TraceObject.CLOB);
int id = getNextTraceId(TraceObject.CLOB);
debugCodeAssign("NClob", TraceObject.CLOB, id, "getNClob(" + columnIndex + ")");
Value v = get(columnIndex);
return v == ValueNull.INSTANCE ? null : new JdbcClob(conn, v, id);
Expand All @@ -3390,7 +3390,7 @@ public NClob getNClob(int columnIndex) throws SQLException {
@Override
public NClob getNClob(String columnLabel) throws SQLException {
try {
int id = getNextId(TraceObject.CLOB);
int id = getNextTraceId(TraceObject.CLOB);
debugCodeAssign("NClob", TraceObject.CLOB, id, "getNClob(" + columnLabel + ")");
Value v = get(columnLabel);
return v == ValueNull.INSTANCE ? null : new JdbcClob(conn, v, id);
Expand Down
Expand Up @@ -66,7 +66,7 @@ public class JdbcStatement extends TraceObject implements Statement {
@Override
public ResultSet executeQuery(String sql) throws SQLException {
try {
int id = getNextId(TraceObject.RESULT_SET);
int id = getNextTraceId(TraceObject.RESULT_SET);
if (isDebugEnabled()) {
debugCodeAssign("ResultSet", TraceObject.RESULT_SET, id, "executeQuery(" + quote(sql) + ")");
}
Expand Down Expand Up @@ -179,7 +179,7 @@ private boolean executeInternal(String sql) throws SQLException {
}
}
}
int id = getNextId(TraceObject.RESULT_SET);
int id = getNextTraceId(TraceObject.RESULT_SET);
checkClosed();
closeOldResultSet();
sql = JdbcConnection.translateSQL(sql, escapeProcessing);
Expand Down Expand Up @@ -714,7 +714,7 @@ public int[] executeBatch() throws SQLException {
@Override
public ResultSet getGeneratedKeys() throws SQLException {
try {
int id = getNextId(TraceObject.RESULT_SET);
int id = getNextTraceId(TraceObject.RESULT_SET);
if (isDebugEnabled()) {
debugCodeAssign("ResultSet", TraceObject.RESULT_SET, id, "getGeneratedKeys()");
}
Expand Down
Expand Up @@ -131,7 +131,7 @@ public String getTraceObjectName() {
* @param type the object type
* @return the new trace object id
*/
protected static int getNextId(int type) {
protected static int getNextTraceId(int type) {
return ID[type]++;
}

Expand Down

0 comments on commit c488c01

Please sign in to comment.