diff --git a/src/main/java/com/alibaba/druid/filter/Filter.java b/src/main/java/com/alibaba/druid/filter/Filter.java index 6a0c2a5ce5..b7ec85617c 100644 --- a/src/main/java/com/alibaba/druid/filter/Filter.java +++ b/src/main/java/com/alibaba/druid/filter/Filter.java @@ -46,7 +46,6 @@ import java.util.Properties; import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidPooledConnection; -import com.alibaba.druid.proxy.config.AbstractDruidFilterConfig; import com.alibaba.druid.proxy.jdbc.CallableStatementProxy; import com.alibaba.druid.proxy.jdbc.ClobProxy; import com.alibaba.druid.proxy.jdbc.ConnectionProxy; @@ -1277,8 +1276,6 @@ public interface Filter { void clob_truncate(FilterChain chain, ClobProxy wrapper, long len) throws SQLException; - void loadConfig(AbstractDruidFilterConfig druidFilterConfig); - void dataSource_releaseConnection(FilterChain chain, DruidPooledConnection connection) throws SQLException; DruidPooledConnection dataSource_getConnection(FilterChain chain, DruidDataSource dataSource, long maxWaitMillis) throws SQLException; diff --git a/src/main/java/com/alibaba/druid/filter/FilterAdapter.java b/src/main/java/com/alibaba/druid/filter/FilterAdapter.java index 32804f030a..4d280bbea6 100644 --- a/src/main/java/com/alibaba/druid/filter/FilterAdapter.java +++ b/src/main/java/com/alibaba/druid/filter/FilterAdapter.java @@ -44,7 +44,6 @@ import javax.management.NotificationBroadcasterSupport; import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidPooledConnection; -import com.alibaba.druid.proxy.config.AbstractDruidFilterConfig; import com.alibaba.druid.proxy.jdbc.CallableStatementProxy; import com.alibaba.druid.proxy.jdbc.ClobProxy; import com.alibaba.druid.proxy.jdbc.ConnectionProxy; @@ -60,10 +59,6 @@ import com.alibaba.druid.proxy.jdbc.StatementProxy; */ public abstract class FilterAdapter extends NotificationBroadcasterSupport implements Filter { - @Override - public void loadConfig(AbstractDruidFilterConfig DruidFilterConfig) { - } - @Override public void init(DataSourceProxy dataSource) { } diff --git a/src/main/java/com/alibaba/druid/filter/FilterChain.java b/src/main/java/com/alibaba/druid/filter/FilterChain.java index fb321e3e3f..1b5aec5b86 100644 --- a/src/main/java/com/alibaba/druid/filter/FilterChain.java +++ b/src/main/java/com/alibaba/druid/filter/FilterChain.java @@ -55,8 +55,9 @@ import com.alibaba.druid.proxy.jdbc.StatementProxy; * @author wenshao */ public interface FilterChain { + DataSourceProxy getDataSource(); - + int getFilterSize(); FilterChain cloneChain(); @@ -176,430 +177,415 @@ public interface FilterChain { // --------- // /////////////// - public boolean resultSet_next(ResultSetProxy resultSet) throws SQLException; + boolean resultSet_next(ResultSetProxy resultSet) throws SQLException; - public void resultSet_close(ResultSetProxy resultSet) throws SQLException; + void resultSet_close(ResultSetProxy resultSet) throws SQLException; - public boolean resultSet_wasNull(ResultSetProxy resultSet) throws SQLException; + boolean resultSet_wasNull(ResultSetProxy resultSet) throws SQLException; - public String resultSet_getString(ResultSetProxy resultSet, int columnIndex) throws SQLException; + String resultSet_getString(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public boolean resultSet_getBoolean(ResultSetProxy resultSet, int columnIndex) throws SQLException; + boolean resultSet_getBoolean(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public byte resultSet_getByte(ResultSetProxy resultSet, int columnIndex) throws SQLException; + byte resultSet_getByte(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public short resultSet_getShort(ResultSetProxy resultSet, int columnIndex) throws SQLException; + short resultSet_getShort(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public int resultSet_getInt(ResultSetProxy resultSet, int columnIndex) throws SQLException; + int resultSet_getInt(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public long resultSet_getLong(ResultSetProxy resultSet, int columnIndex) throws SQLException; + long resultSet_getLong(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public float resultSet_getFloat(ResultSetProxy resultSet, int columnIndex) throws SQLException; + float resultSet_getFloat(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public double resultSet_getDouble(ResultSetProxy resultSet, int columnIndex) throws SQLException; + double resultSet_getDouble(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public BigDecimal resultSet_getBigDecimal(ResultSetProxy resultSet, int columnIndex, int scale) throws SQLException; + BigDecimal resultSet_getBigDecimal(ResultSetProxy resultSet, int columnIndex, int scale) throws SQLException; - public byte[] resultSet_getBytes(ResultSetProxy resultSet, int columnIndex) throws SQLException; + byte[] resultSet_getBytes(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public java.sql.Date resultSet_getDate(ResultSetProxy resultSet, int columnIndex) throws SQLException; + java.sql.Date resultSet_getDate(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public java.sql.Time resultSet_getTime(ResultSetProxy resultSet, int columnIndex) throws SQLException; + java.sql.Time resultSet_getTime(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public java.sql.Timestamp resultSet_getTimestamp(ResultSetProxy resultSet, int columnIndex) throws SQLException; + java.sql.Timestamp resultSet_getTimestamp(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public java.io.InputStream resultSet_getAsciiStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; + java.io.InputStream resultSet_getAsciiStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public java.io.InputStream resultSet_getUnicodeStream(ResultSetProxy resultSet, int columnIndex) - throws SQLException; + java.io.InputStream resultSet_getUnicodeStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public java.io.InputStream resultSet_getBinaryStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; + java.io.InputStream resultSet_getBinaryStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public String resultSet_getString(ResultSetProxy resultSet, String columnLabel) throws SQLException; + String resultSet_getString(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public boolean resultSet_getBoolean(ResultSetProxy resultSet, String columnLabel) throws SQLException; + boolean resultSet_getBoolean(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public byte resultSet_getByte(ResultSetProxy resultSet, String columnLabel) throws SQLException; + byte resultSet_getByte(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public short resultSet_getShort(ResultSetProxy resultSet, String columnLabel) throws SQLException; + short resultSet_getShort(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public int resultSet_getInt(ResultSetProxy resultSet, String columnLabel) throws SQLException; + int resultSet_getInt(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public long resultSet_getLong(ResultSetProxy resultSet, String columnLabel) throws SQLException; + long resultSet_getLong(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public float resultSet_getFloat(ResultSetProxy resultSet, String columnLabel) throws SQLException; + float resultSet_getFloat(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public double resultSet_getDouble(ResultSetProxy resultSet, String columnLabel) throws SQLException; + double resultSet_getDouble(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public BigDecimal resultSet_getBigDecimal(ResultSetProxy resultSet, String columnLabel, int scale) - throws SQLException; + BigDecimal resultSet_getBigDecimal(ResultSetProxy resultSet, String columnLabel, int scale) throws SQLException; - public byte[] resultSet_getBytes(ResultSetProxy resultSet, String columnLabel) throws SQLException; + byte[] resultSet_getBytes(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public java.sql.Date resultSet_getDate(ResultSetProxy resultSet, String columnLabel) throws SQLException; + java.sql.Date resultSet_getDate(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public java.sql.Time resultSet_getTime(ResultSetProxy resultSet, String columnLabel) throws SQLException; + java.sql.Time resultSet_getTime(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public java.sql.Timestamp resultSet_getTimestamp(ResultSetProxy resultSet, String columnLabel) throws SQLException; + java.sql.Timestamp resultSet_getTimestamp(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public java.io.InputStream resultSet_getAsciiStream(ResultSetProxy resultSet, String columnLabel) - throws SQLException; + java.io.InputStream resultSet_getAsciiStream(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public java.io.InputStream resultSet_getUnicodeStream(ResultSetProxy resultSet, String columnLabel) + java.io.InputStream resultSet_getUnicodeStream(ResultSetProxy resultSet, String columnLabel) throws SQLException; + + java.io.InputStream resultSet_getBinaryStream(ResultSetProxy resultSet, String columnLabel) throws SQLException; + + SQLWarning resultSet_getWarnings(ResultSetProxy resultSet) throws SQLException; + + void resultSet_clearWarnings(ResultSetProxy resultSet) throws SQLException; + + String resultSet_getCursorName(ResultSetProxy resultSet) throws SQLException; + + ResultSetMetaData resultSet_getMetaData(ResultSetProxy resultSet) throws SQLException; + + Object resultSet_getObject(ResultSetProxy resultSet, int columnIndex) throws SQLException; + + Object resultSet_getObject(ResultSetProxy resultSet, String columnLabel) throws SQLException; + + int resultSet_findColumn(ResultSetProxy resultSet, String columnLabel) throws SQLException; + + java.io.Reader resultSet_getCharacterStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; + + java.io.Reader resultSet_getCharacterStream(ResultSetProxy resultSet, String columnLabel) throws SQLException; + + BigDecimal resultSet_getBigDecimal(ResultSetProxy resultSet, int columnIndex) throws SQLException; + + BigDecimal resultSet_getBigDecimal(ResultSetProxy resultSet, String columnLabel) throws SQLException; + + boolean resultSet_isBeforeFirst(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_isAfterLast(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_isFirst(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_isLast(ResultSetProxy resultSet) throws SQLException; + + void resultSet_beforeFirst(ResultSetProxy resultSet) throws SQLException; + + void resultSet_afterLast(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_first(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_last(ResultSetProxy resultSet) throws SQLException; + + int resultSet_getRow(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_absolute(ResultSetProxy resultSet, int row) throws SQLException; + + boolean resultSet_relative(ResultSetProxy resultSet, int rows) throws SQLException; + + boolean resultSet_previous(ResultSetProxy resultSet) throws SQLException; + + void resultSet_setFetchDirection(ResultSetProxy resultSet, int direction) throws SQLException; + + int resultSet_getFetchDirection(ResultSetProxy resultSet) throws SQLException; + + void resultSet_setFetchSize(ResultSetProxy resultSet, int rows) throws SQLException; + + int resultSet_getFetchSize(ResultSetProxy resultSet) throws SQLException; + + int resultSet_getType(ResultSetProxy resultSet) throws SQLException; + + int resultSet_getConcurrency(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_rowUpdated(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_rowInserted(ResultSetProxy resultSet) throws SQLException; + + boolean resultSet_rowDeleted(ResultSetProxy resultSet) throws SQLException; + + void resultSet_updateNull(ResultSetProxy resultSet, int columnIndex) throws SQLException; + + void resultSet_updateBoolean(ResultSetProxy resultSet, int columnIndex, boolean x) throws SQLException; + + void resultSet_updateByte(ResultSetProxy resultSet, int columnIndex, byte x) throws SQLException; + + void resultSet_updateShort(ResultSetProxy resultSet, int columnIndex, short x) throws SQLException; + + void resultSet_updateInt(ResultSetProxy resultSet, int columnIndex, int x) throws SQLException; + + void resultSet_updateLong(ResultSetProxy resultSet, int columnIndex, long x) throws SQLException; + + void resultSet_updateFloat(ResultSetProxy resultSet, int columnIndex, float x) throws SQLException; + + void resultSet_updateDouble(ResultSetProxy resultSet, int columnIndex, double x) throws SQLException; + + void resultSet_updateBigDecimal(ResultSetProxy resultSet, int columnIndex, BigDecimal x) throws SQLException; + + void resultSet_updateString(ResultSetProxy resultSet, int columnIndex, String x) throws SQLException; + + void resultSet_updateBytes(ResultSetProxy resultSet, int columnIndex, byte x[]) throws SQLException; + + void resultSet_updateDate(ResultSetProxy resultSet, int columnIndex, java.sql.Date x) throws SQLException; + + void resultSet_updateTime(ResultSetProxy resultSet, int columnIndex, java.sql.Time x) throws SQLException; + + void resultSet_updateTimestamp(ResultSetProxy resultSet, int columnIndex, java.sql.Timestamp x) throws SQLException; + + void resultSet_updateAsciiStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x, int length) + throws SQLException; + + void resultSet_updateBinaryStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x, int length) + throws SQLException; + + void resultSet_updateCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x, int length) + throws SQLException; + + void resultSet_updateObject(ResultSetProxy resultSet, int columnIndex, Object x, int scaleOrLength) throws SQLException; - public java.io.InputStream resultSet_getBinaryStream(ResultSetProxy resultSet, String columnLabel) + void resultSet_updateObject(ResultSetProxy resultSet, int columnIndex, Object x) throws SQLException; + + void resultSet_updateNull(ResultSetProxy resultSet, String columnLabel) throws SQLException; + + void resultSet_updateBoolean(ResultSetProxy resultSet, String columnLabel, boolean x) throws SQLException; + + void resultSet_updateByte(ResultSetProxy resultSet, String columnLabel, byte x) throws SQLException; + + void resultSet_updateShort(ResultSetProxy resultSet, String columnLabel, short x) throws SQLException; + + void resultSet_updateInt(ResultSetProxy resultSet, String columnLabel, int x) throws SQLException; + + void resultSet_updateLong(ResultSetProxy resultSet, String columnLabel, long x) throws SQLException; + + void resultSet_updateFloat(ResultSetProxy resultSet, String columnLabel, float x) throws SQLException; + + void resultSet_updateDouble(ResultSetProxy resultSet, String columnLabel, double x) throws SQLException; + + void resultSet_updateBigDecimal(ResultSetProxy resultSet, String columnLabel, BigDecimal x) throws SQLException; + + void resultSet_updateString(ResultSetProxy resultSet, String columnLabel, String x) throws SQLException; + + void resultSet_updateBytes(ResultSetProxy resultSet, String columnLabel, byte x[]) throws SQLException; + + void resultSet_updateDate(ResultSetProxy resultSet, String columnLabel, java.sql.Date x) throws SQLException; + + void resultSet_updateTime(ResultSetProxy resultSet, String columnLabel, java.sql.Time x) throws SQLException; + + void resultSet_updateTimestamp(ResultSetProxy resultSet, String columnLabel, java.sql.Timestamp x) throws SQLException; - public SQLWarning resultSet_getWarnings(ResultSetProxy resultSet) throws SQLException; + void resultSet_updateAsciiStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x, int length) + throws SQLException; - public void resultSet_clearWarnings(ResultSetProxy resultSet) throws SQLException; + void resultSet_updateBinaryStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x, int length) + throws SQLException; - public String resultSet_getCursorName(ResultSetProxy resultSet) throws SQLException; + void resultSet_updateCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader, int length) + throws SQLException; - public ResultSetMetaData resultSet_getMetaData(ResultSetProxy resultSet) throws SQLException; - - public Object resultSet_getObject(ResultSetProxy resultSet, int columnIndex) throws SQLException; - - public Object resultSet_getObject(ResultSetProxy resultSet, String columnLabel) throws SQLException; - - public int resultSet_findColumn(ResultSetProxy resultSet, String columnLabel) throws SQLException; - - public java.io.Reader resultSet_getCharacterStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; - - public java.io.Reader resultSet_getCharacterStream(ResultSetProxy resultSet, String columnLabel) - throws SQLException; - - public BigDecimal resultSet_getBigDecimal(ResultSetProxy resultSet, int columnIndex) throws SQLException; - - public BigDecimal resultSet_getBigDecimal(ResultSetProxy resultSet, String columnLabel) throws SQLException; - - public boolean resultSet_isBeforeFirst(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_isAfterLast(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_isFirst(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_isLast(ResultSetProxy resultSet) throws SQLException; - - public void resultSet_beforeFirst(ResultSetProxy resultSet) throws SQLException; - - public void resultSet_afterLast(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_first(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_last(ResultSetProxy resultSet) throws SQLException; - - public int resultSet_getRow(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_absolute(ResultSetProxy resultSet, int row) throws SQLException; - - public boolean resultSet_relative(ResultSetProxy resultSet, int rows) throws SQLException; - - public boolean resultSet_previous(ResultSetProxy resultSet) throws SQLException; - - public void resultSet_setFetchDirection(ResultSetProxy resultSet, int direction) throws SQLException; - - public int resultSet_getFetchDirection(ResultSetProxy resultSet) throws SQLException; - - public void resultSet_setFetchSize(ResultSetProxy resultSet, int rows) throws SQLException; - - public int resultSet_getFetchSize(ResultSetProxy resultSet) throws SQLException; - - public int resultSet_getType(ResultSetProxy resultSet) throws SQLException; - - public int resultSet_getConcurrency(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_rowUpdated(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_rowInserted(ResultSetProxy resultSet) throws SQLException; - - public boolean resultSet_rowDeleted(ResultSetProxy resultSet) throws SQLException; - - public void resultSet_updateNull(ResultSetProxy resultSet, int columnIndex) throws SQLException; - - public void resultSet_updateBoolean(ResultSetProxy resultSet, int columnIndex, boolean x) throws SQLException; - - public void resultSet_updateByte(ResultSetProxy resultSet, int columnIndex, byte x) throws SQLException; - - public void resultSet_updateShort(ResultSetProxy resultSet, int columnIndex, short x) throws SQLException; - - public void resultSet_updateInt(ResultSetProxy resultSet, int columnIndex, int x) throws SQLException; - - public void resultSet_updateLong(ResultSetProxy resultSet, int columnIndex, long x) throws SQLException; - - public void resultSet_updateFloat(ResultSetProxy resultSet, int columnIndex, float x) throws SQLException; - - public void resultSet_updateDouble(ResultSetProxy resultSet, int columnIndex, double x) throws SQLException; - - public void resultSet_updateBigDecimal(ResultSetProxy resultSet, int columnIndex, BigDecimal x) throws SQLException; - - public void resultSet_updateString(ResultSetProxy resultSet, int columnIndex, String x) throws SQLException; - - public void resultSet_updateBytes(ResultSetProxy resultSet, int columnIndex, byte x[]) throws SQLException; - - public void resultSet_updateDate(ResultSetProxy resultSet, int columnIndex, java.sql.Date x) throws SQLException; - - public void resultSet_updateTime(ResultSetProxy resultSet, int columnIndex, java.sql.Time x) throws SQLException; - - public void resultSet_updateTimestamp(ResultSetProxy resultSet, int columnIndex, java.sql.Timestamp x) + void resultSet_updateObject(ResultSetProxy resultSet, String columnLabel, Object x, int scaleOrLength) throws SQLException; - public void resultSet_updateAsciiStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x, int length) - throws SQLException; + void resultSet_updateObject(ResultSetProxy resultSet, String columnLabel, Object x) throws SQLException; - public void resultSet_updateBinaryStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x, - int length) throws SQLException; + void resultSet_insertRow(ResultSetProxy resultSet) throws SQLException; - public void resultSet_updateCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x, int length) - throws SQLException; + void resultSet_updateRow(ResultSetProxy resultSet) throws SQLException; - public void resultSet_updateObject(ResultSetProxy resultSet, int columnIndex, Object x, int scaleOrLength) + void resultSet_deleteRow(ResultSetProxy resultSet) throws SQLException; + + void resultSet_refreshRow(ResultSetProxy resultSet) throws SQLException; + + void resultSet_cancelRowUpdates(ResultSetProxy resultSet) throws SQLException; + + void resultSet_moveToInsertRow(ResultSetProxy resultSet) throws SQLException; + + void resultSet_moveToCurrentRow(ResultSetProxy resultSet) throws SQLException; + + Statement resultSet_getStatement(ResultSetProxy resultSet) throws SQLException; + + Object resultSet_getObject(ResultSetProxy resultSet, int columnIndex, java.util.Map> map) throws SQLException; - public void resultSet_updateObject(ResultSetProxy resultSet, int columnIndex, Object x) throws SQLException; + Ref resultSet_getRef(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public void resultSet_updateNull(ResultSetProxy resultSet, String columnLabel) throws SQLException; + Blob resultSet_getBlob(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public void resultSet_updateBoolean(ResultSetProxy resultSet, String columnLabel, boolean x) throws SQLException; + Clob resultSet_getClob(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public void resultSet_updateByte(ResultSetProxy resultSet, String columnLabel, byte x) throws SQLException; + Array resultSet_getArray(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public void resultSet_updateShort(ResultSetProxy resultSet, String columnLabel, short x) throws SQLException; - - public void resultSet_updateInt(ResultSetProxy resultSet, String columnLabel, int x) throws SQLException; - - public void resultSet_updateLong(ResultSetProxy resultSet, String columnLabel, long x) throws SQLException; - - public void resultSet_updateFloat(ResultSetProxy resultSet, String columnLabel, float x) throws SQLException; - - public void resultSet_updateDouble(ResultSetProxy resultSet, String columnLabel, double x) throws SQLException; - - public void resultSet_updateBigDecimal(ResultSetProxy resultSet, String columnLabel, BigDecimal x) - throws SQLException; - - public void resultSet_updateString(ResultSetProxy resultSet, String columnLabel, String x) throws SQLException; - - public void resultSet_updateBytes(ResultSetProxy resultSet, String columnLabel, byte x[]) throws SQLException; - - public void resultSet_updateDate(ResultSetProxy resultSet, String columnLabel, java.sql.Date x) throws SQLException; - - public void resultSet_updateTime(ResultSetProxy resultSet, String columnLabel, java.sql.Time x) throws SQLException; - - public void resultSet_updateTimestamp(ResultSetProxy resultSet, String columnLabel, java.sql.Timestamp x) - throws SQLException; - - public void resultSet_updateAsciiStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x, - int length) throws SQLException; - - public void resultSet_updateBinaryStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x, - int length) throws SQLException; - - public void resultSet_updateCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader, - int length) throws SQLException; - - public void resultSet_updateObject(ResultSetProxy resultSet, String columnLabel, Object x, int scaleOrLength) + Object resultSet_getObject(ResultSetProxy resultSet, String columnLabel, java.util.Map> map) throws SQLException; - public void resultSet_updateObject(ResultSetProxy resultSet, String columnLabel, Object x) throws SQLException; + Ref resultSet_getRef(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public void resultSet_insertRow(ResultSetProxy resultSet) throws SQLException; + Blob resultSet_getBlob(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public void resultSet_updateRow(ResultSetProxy resultSet) throws SQLException; + Clob resultSet_getClob(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public void resultSet_deleteRow(ResultSetProxy resultSet) throws SQLException; + Array resultSet_getArray(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public void resultSet_refreshRow(ResultSetProxy resultSet) throws SQLException; + java.sql.Date resultSet_getDate(ResultSetProxy resultSet, int columnIndex, Calendar cal) throws SQLException; - public void resultSet_cancelRowUpdates(ResultSetProxy resultSet) throws SQLException; + java.sql.Date resultSet_getDate(ResultSetProxy resultSet, String columnLabel, Calendar cal) throws SQLException; - public void resultSet_moveToInsertRow(ResultSetProxy resultSet) throws SQLException; + java.sql.Time resultSet_getTime(ResultSetProxy resultSet, int columnIndex, Calendar cal) throws SQLException; - public void resultSet_moveToCurrentRow(ResultSetProxy resultSet) throws SQLException; + java.sql.Time resultSet_getTime(ResultSetProxy resultSet, String columnLabel, Calendar cal) throws SQLException; - public Statement resultSet_getStatement(ResultSetProxy resultSet) throws SQLException; - - public Object resultSet_getObject(ResultSetProxy resultSet, int columnIndex, java.util.Map> map) - throws SQLException; - - public Ref resultSet_getRef(ResultSetProxy resultSet, int columnIndex) throws SQLException; - - public Blob resultSet_getBlob(ResultSetProxy resultSet, int columnIndex) throws SQLException; - - public Clob resultSet_getClob(ResultSetProxy resultSet, int columnIndex) throws SQLException; - - public Array resultSet_getArray(ResultSetProxy resultSet, int columnIndex) throws SQLException; - - public Object resultSet_getObject(ResultSetProxy resultSet, String columnLabel, java.util.Map> map) - throws SQLException; - - public Ref resultSet_getRef(ResultSetProxy resultSet, String columnLabel) throws SQLException; - - public Blob resultSet_getBlob(ResultSetProxy resultSet, String columnLabel) throws SQLException; - - public Clob resultSet_getClob(ResultSetProxy resultSet, String columnLabel) throws SQLException; - - public Array resultSet_getArray(ResultSetProxy resultSet, String columnLabel) throws SQLException; - - public java.sql.Date resultSet_getDate(ResultSetProxy resultSet, int columnIndex, Calendar cal) throws SQLException; - - public java.sql.Date resultSet_getDate(ResultSetProxy resultSet, String columnLabel, Calendar cal) + java.sql.Timestamp resultSet_getTimestamp(ResultSetProxy resultSet, int columnIndex, Calendar cal) throws SQLException; - public java.sql.Time resultSet_getTime(ResultSetProxy resultSet, int columnIndex, Calendar cal) throws SQLException; + java.sql.Timestamp resultSet_getTimestamp(ResultSetProxy resultSet, String columnLabel, Calendar cal) + throws SQLException; - public java.sql.Time resultSet_getTime(ResultSetProxy resultSet, String columnLabel, Calendar cal) - throws SQLException; + java.net.URL resultSet_getURL(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public java.sql.Timestamp resultSet_getTimestamp(ResultSetProxy resultSet, int columnIndex, Calendar cal) - throws SQLException; + java.net.URL resultSet_getURL(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public java.sql.Timestamp resultSet_getTimestamp(ResultSetProxy resultSet, String columnLabel, Calendar cal) - throws SQLException; + void resultSet_updateRef(ResultSetProxy resultSet, int columnIndex, java.sql.Ref x) throws SQLException; - public java.net.URL resultSet_getURL(ResultSetProxy resultSet, int columnIndex) throws SQLException; + void resultSet_updateRef(ResultSetProxy resultSet, String columnLabel, java.sql.Ref x) throws SQLException; - public java.net.URL resultSet_getURL(ResultSetProxy resultSet, String columnLabel) throws SQLException; + void resultSet_updateBlob(ResultSetProxy resultSet, int columnIndex, java.sql.Blob x) throws SQLException; - public void resultSet_updateRef(ResultSetProxy resultSet, int columnIndex, java.sql.Ref x) throws SQLException; + void resultSet_updateBlob(ResultSetProxy resultSet, String columnLabel, java.sql.Blob x) throws SQLException; - public void resultSet_updateRef(ResultSetProxy resultSet, String columnLabel, java.sql.Ref x) throws SQLException; + void resultSet_updateClob(ResultSetProxy resultSet, int columnIndex, java.sql.Clob x) throws SQLException; - public void resultSet_updateBlob(ResultSetProxy resultSet, int columnIndex, java.sql.Blob x) throws SQLException; + void resultSet_updateClob(ResultSetProxy resultSet, String columnLabel, java.sql.Clob x) throws SQLException; - public void resultSet_updateBlob(ResultSetProxy resultSet, String columnLabel, java.sql.Blob x) throws SQLException; + void resultSet_updateArray(ResultSetProxy resultSet, int columnIndex, java.sql.Array x) throws SQLException; - public void resultSet_updateClob(ResultSetProxy resultSet, int columnIndex, java.sql.Clob x) throws SQLException; + void resultSet_updateArray(ResultSetProxy resultSet, String columnLabel, java.sql.Array x) throws SQLException; - public void resultSet_updateClob(ResultSetProxy resultSet, String columnLabel, java.sql.Clob x) throws SQLException; + RowId resultSet_getRowId(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public void resultSet_updateArray(ResultSetProxy resultSet, int columnIndex, java.sql.Array x) throws SQLException; + RowId resultSet_getRowId(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public void resultSet_updateArray(ResultSetProxy resultSet, String columnLabel, java.sql.Array x) - throws SQLException; + void resultSet_updateRowId(ResultSetProxy resultSet, int columnIndex, RowId x) throws SQLException; - public RowId resultSet_getRowId(ResultSetProxy resultSet, int columnIndex) throws SQLException; + void resultSet_updateRowId(ResultSetProxy resultSet, String columnLabel, RowId x) throws SQLException; - public RowId resultSet_getRowId(ResultSetProxy resultSet, String columnLabel) throws SQLException; + int resultSet_getHoldability(ResultSetProxy resultSet) throws SQLException; - public void resultSet_updateRowId(ResultSetProxy resultSet, int columnIndex, RowId x) throws SQLException; + boolean resultSet_isClosed(ResultSetProxy resultSet) throws SQLException; - public void resultSet_updateRowId(ResultSetProxy resultSet, String columnLabel, RowId x) throws SQLException; + void resultSet_updateNString(ResultSetProxy resultSet, int columnIndex, String nString) throws SQLException; - public int resultSet_getHoldability(ResultSetProxy resultSet) throws SQLException; + void resultSet_updateNString(ResultSetProxy resultSet, String columnLabel, String nString) throws SQLException; - public boolean resultSet_isClosed(ResultSetProxy resultSet) throws SQLException; + void resultSet_updateNClob(ResultSetProxy resultSet, int columnIndex, NClob nClob) throws SQLException; - public void resultSet_updateNString(ResultSetProxy resultSet, int columnIndex, String nString) throws SQLException; + void resultSet_updateNClob(ResultSetProxy resultSet, String columnLabel, NClob nClob) throws SQLException; - public void resultSet_updateNString(ResultSetProxy resultSet, String columnLabel, String nString) - throws SQLException; + NClob resultSet_getNClob(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public void resultSet_updateNClob(ResultSetProxy resultSet, int columnIndex, NClob nClob) throws SQLException; + NClob resultSet_getNClob(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public void resultSet_updateNClob(ResultSetProxy resultSet, String columnLabel, NClob nClob) throws SQLException; + SQLXML resultSet_getSQLXML(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public NClob resultSet_getNClob(ResultSetProxy resultSet, int columnIndex) throws SQLException; + SQLXML resultSet_getSQLXML(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public NClob resultSet_getNClob(ResultSetProxy resultSet, String columnLabel) throws SQLException; + void resultSet_updateSQLXML(ResultSetProxy resultSet, int columnIndex, SQLXML xmlObject) throws SQLException; - public SQLXML resultSet_getSQLXML(ResultSetProxy resultSet, int columnIndex) throws SQLException; + void resultSet_updateSQLXML(ResultSetProxy resultSet, String columnLabel, SQLXML xmlObject) throws SQLException; - public SQLXML resultSet_getSQLXML(ResultSetProxy resultSet, String columnLabel) throws SQLException; + String resultSet_getNString(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public void resultSet_updateSQLXML(ResultSetProxy resultSet, int columnIndex, SQLXML xmlObject) throws SQLException; + String resultSet_getNString(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public void resultSet_updateSQLXML(ResultSetProxy resultSet, String columnLabel, SQLXML xmlObject) - throws SQLException; + java.io.Reader resultSet_getNCharacterStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; - public String resultSet_getNString(ResultSetProxy resultSet, int columnIndex) throws SQLException; + java.io.Reader resultSet_getNCharacterStream(ResultSetProxy resultSet, String columnLabel) throws SQLException; - public String resultSet_getNString(ResultSetProxy resultSet, String columnLabel) throws SQLException; + void resultSet_updateNCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x, long length) + throws SQLException; - public java.io.Reader resultSet_getNCharacterStream(ResultSetProxy resultSet, int columnIndex) throws SQLException; + void resultSet_updateNCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader, + long length) throws SQLException; - public java.io.Reader resultSet_getNCharacterStream(ResultSetProxy resultSet, String columnLabel) - throws SQLException; + void resultSet_updateAsciiStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x, long length) + throws SQLException; - public void resultSet_updateNCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x, - long length) throws SQLException; - - public void resultSet_updateNCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader, - long length) throws SQLException; - - public void resultSet_updateAsciiStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x, - long length) throws SQLException; - - public void resultSet_updateBinaryStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x, - long length) throws SQLException; - - public void resultSet_updateCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x, long length) - throws SQLException; - - public void resultSet_updateAsciiStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x, - long length) throws SQLException; - - public void resultSet_updateBinaryStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x, - long length) throws SQLException; - - public void resultSet_updateCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader, - long length) throws SQLException; - - public void resultSet_updateBlob(ResultSetProxy resultSet, int columnIndex, InputStream inputStream, long length) - throws SQLException; - - public void resultSet_updateBlob(ResultSetProxy resultSet, String columnLabel, InputStream inputStream, long length) - throws SQLException; - - public void resultSet_updateClob(ResultSetProxy resultSet, int columnIndex, Reader reader, long length) - throws SQLException; - - public void resultSet_updateClob(ResultSetProxy resultSet, String columnLabel, Reader reader, long length) - throws SQLException; - - public void resultSet_updateNClob(ResultSetProxy resultSet, int columnIndex, Reader reader, long length) - throws SQLException; - - public void resultSet_updateNClob(ResultSetProxy resultSet, String columnLabel, Reader reader, long length) - throws SQLException; - - public void resultSet_updateNCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x) - throws SQLException; - - public void resultSet_updateNCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader) - throws SQLException; - - public void resultSet_updateAsciiStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x) - throws SQLException; - - public void resultSet_updateBinaryStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x) - throws SQLException; - - public void resultSet_updateCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x) - throws SQLException; - - public void resultSet_updateAsciiStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x) - throws SQLException; - - public void resultSet_updateBinaryStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x) - throws SQLException; - - public void resultSet_updateCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader) + void resultSet_updateBinaryStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x, long length) throws SQLException; - public void resultSet_updateBlob(ResultSetProxy resultSet, int columnIndex, InputStream inputStream) + void resultSet_updateCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x, long length) + throws SQLException; + + void resultSet_updateAsciiStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x, long length) + throws SQLException; + + void resultSet_updateBinaryStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x, long length) + throws SQLException; + + void resultSet_updateCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader, + long length) throws SQLException; + + void resultSet_updateBlob(ResultSetProxy resultSet, int columnIndex, InputStream inputStream, long length) + throws SQLException; + + void resultSet_updateBlob(ResultSetProxy resultSet, String columnLabel, InputStream inputStream, long length) + throws SQLException; + + void resultSet_updateClob(ResultSetProxy resultSet, int columnIndex, Reader reader, long length) + throws SQLException; + + void resultSet_updateClob(ResultSetProxy resultSet, String columnLabel, Reader reader, long length) + throws SQLException; + + void resultSet_updateNClob(ResultSetProxy resultSet, int columnIndex, Reader reader, long length) + throws SQLException; + + void resultSet_updateNClob(ResultSetProxy resultSet, String columnLabel, Reader reader, long length) throws SQLException; - public void resultSet_updateBlob(ResultSetProxy resultSet, String columnLabel, InputStream inputStream) - throws SQLException; + void resultSet_updateNCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x) + throws SQLException; - public void resultSet_updateClob(ResultSetProxy resultSet, int columnIndex, Reader reader) throws SQLException; + void resultSet_updateNCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader) + throws SQLException; - public void resultSet_updateClob(ResultSetProxy resultSet, String columnLabel, Reader reader) throws SQLException; + void resultSet_updateAsciiStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x) + throws SQLException; - public void resultSet_updateNClob(ResultSetProxy resultSet, int columnIndex, Reader reader) throws SQLException; + void resultSet_updateBinaryStream(ResultSetProxy resultSet, int columnIndex, java.io.InputStream x) + throws SQLException; - public void resultSet_updateNClob(ResultSetProxy resultSet, String columnLabel, Reader reader) throws SQLException; + void resultSet_updateCharacterStream(ResultSetProxy resultSet, int columnIndex, java.io.Reader x) + throws SQLException; + + void resultSet_updateAsciiStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x) + throws SQLException; + + void resultSet_updateBinaryStream(ResultSetProxy resultSet, String columnLabel, java.io.InputStream x) + throws SQLException; + + void resultSet_updateCharacterStream(ResultSetProxy resultSet, String columnLabel, java.io.Reader reader) + throws SQLException; + + void resultSet_updateBlob(ResultSetProxy resultSet, int columnIndex, InputStream inputStream) throws SQLException; + + void resultSet_updateBlob(ResultSetProxy resultSet, String columnLabel, InputStream inputStream) + throws SQLException; + + void resultSet_updateClob(ResultSetProxy resultSet, int columnIndex, Reader reader) throws SQLException; + + void resultSet_updateClob(ResultSetProxy resultSet, String columnLabel, Reader reader) throws SQLException; + + void resultSet_updateNClob(ResultSetProxy resultSet, int columnIndex, Reader reader) throws SQLException; + + void resultSet_updateNClob(ResultSetProxy resultSet, String columnLabel, Reader reader) throws SQLException; // //////////////////////////////////// @@ -685,497 +671,465 @@ public interface FilterChain { // //////////////////// - public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException; + ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException; - public int preparedStatement_executeUpdate(PreparedStatementProxy statement) throws SQLException; + int preparedStatement_executeUpdate(PreparedStatementProxy statement) throws SQLException; - public void preparedStatement_setNull(PreparedStatementProxy statement, int parameterIndex, int sqlType) + void preparedStatement_setNull(PreparedStatementProxy statement, int parameterIndex, int sqlType) + throws SQLException; + + void preparedStatement_setBoolean(PreparedStatementProxy statement, int parameterIndex, boolean x) + throws SQLException; + + void preparedStatement_setByte(PreparedStatementProxy statement, int parameterIndex, byte x) throws SQLException; + + void preparedStatement_setShort(PreparedStatementProxy statement, int parameterIndex, short x) throws SQLException; + + void preparedStatement_setInt(PreparedStatementProxy statement, int parameterIndex, int x) throws SQLException; + + void preparedStatement_setLong(PreparedStatementProxy statement, int parameterIndex, long x) throws SQLException; + + void preparedStatement_setFloat(PreparedStatementProxy statement, int parameterIndex, float x) throws SQLException; + + void preparedStatement_setDouble(PreparedStatementProxy statement, int parameterIndex, double x) + throws SQLException; + + void preparedStatement_setBigDecimal(PreparedStatementProxy statement, int parameterIndex, BigDecimal x) throws SQLException; - public void preparedStatement_setBoolean(PreparedStatementProxy statement, int parameterIndex, boolean x) - throws SQLException; + void preparedStatement_setString(PreparedStatementProxy statement, int parameterIndex, String x) + throws SQLException; - public void preparedStatement_setByte(PreparedStatementProxy statement, int parameterIndex, byte x) - throws SQLException; + void preparedStatement_setBytes(PreparedStatementProxy statement, int parameterIndex, byte x[]) throws SQLException; - public void preparedStatement_setShort(PreparedStatementProxy statement, int parameterIndex, short x) + void preparedStatement_setDate(PreparedStatementProxy statement, int parameterIndex, java.sql.Date x) throws SQLException; - public void preparedStatement_setInt(PreparedStatementProxy statement, int parameterIndex, int x) - throws SQLException; - - public void preparedStatement_setLong(PreparedStatementProxy statement, int parameterIndex, long x) - throws SQLException; - - public void preparedStatement_setFloat(PreparedStatementProxy statement, int parameterIndex, float x) + void preparedStatement_setTime(PreparedStatementProxy statement, int parameterIndex, java.sql.Time x) throws SQLException; - public void preparedStatement_setDouble(PreparedStatementProxy statement, int parameterIndex, double x) - throws SQLException; - - public void preparedStatement_setBigDecimal(PreparedStatementProxy statement, int parameterIndex, BigDecimal x) + void preparedStatement_setTimestamp(PreparedStatementProxy statement, int parameterIndex, java.sql.Timestamp x) throws SQLException; - public void preparedStatement_setString(PreparedStatementProxy statement, int parameterIndex, String x) - throws SQLException; + void preparedStatement_setAsciiStream(PreparedStatementProxy statement, int parameterIndex, java.io.InputStream x, + int length) throws SQLException; - public void preparedStatement_setBytes(PreparedStatementProxy statement, int parameterIndex, byte x[]) - throws SQLException; + void preparedStatement_setUnicodeStream(PreparedStatementProxy statement, int parameterIndex, + java.io.InputStream x, int length) throws SQLException; - public void preparedStatement_setDate(PreparedStatementProxy statement, int parameterIndex, java.sql.Date x) - throws SQLException; + void preparedStatement_setBinaryStream(PreparedStatementProxy statement, int parameterIndex, java.io.InputStream x, + int length) throws SQLException; - public void preparedStatement_setTime(PreparedStatementProxy statement, int parameterIndex, java.sql.Time x) - throws SQLException; + void preparedStatement_clearParameters(PreparedStatementProxy statement) throws SQLException; - public void preparedStatement_setTimestamp(PreparedStatementProxy statement, int parameterIndex, - java.sql.Timestamp x) throws SQLException; + void preparedStatement_setObject(PreparedStatementProxy statement, int parameterIndex, Object x, int targetSqlType) + throws SQLException; - public void preparedStatement_setAsciiStream(PreparedStatementProxy statement, int parameterIndex, - java.io.InputStream x, int length) throws SQLException; + void preparedStatement_setObject(PreparedStatementProxy statement, int parameterIndex, Object x) + throws SQLException; - public void preparedStatement_setUnicodeStream(PreparedStatementProxy statement, int parameterIndex, - java.io.InputStream x, int length) throws SQLException; + boolean preparedStatement_execute(PreparedStatementProxy statement) throws SQLException; - public void preparedStatement_setBinaryStream(PreparedStatementProxy statement, int parameterIndex, - java.io.InputStream x, int length) throws SQLException; + void preparedStatement_addBatch(PreparedStatementProxy statement) throws SQLException; - public void preparedStatement_clearParameters(PreparedStatementProxy statement) throws SQLException; + void preparedStatement_setCharacterStream(PreparedStatementProxy statement, int parameterIndex, + java.io.Reader reader, int length) throws SQLException; - public void preparedStatement_setObject(PreparedStatementProxy statement, int parameterIndex, Object x, - int targetSqlType) throws SQLException; + void preparedStatement_setRef(PreparedStatementProxy statement, int parameterIndex, Ref x) throws SQLException; - public void preparedStatement_setObject(PreparedStatementProxy statement, int parameterIndex, Object x) - throws SQLException; + void preparedStatement_setBlob(PreparedStatementProxy statement, int parameterIndex, Blob x) throws SQLException; - public boolean preparedStatement_execute(PreparedStatementProxy statement) throws SQLException; + void preparedStatement_setClob(PreparedStatementProxy statement, int parameterIndex, Clob x) throws SQLException; - public void preparedStatement_addBatch(PreparedStatementProxy statement) throws SQLException; + void preparedStatement_setArray(PreparedStatementProxy statement, int parameterIndex, Array x) throws SQLException; - public void preparedStatement_setCharacterStream(PreparedStatementProxy statement, int parameterIndex, - java.io.Reader reader, int length) throws SQLException; + ResultSetMetaData preparedStatement_getMetaData(PreparedStatementProxy statement) throws SQLException; - public void preparedStatement_setRef(PreparedStatementProxy statement, int parameterIndex, Ref x) - throws SQLException; + void preparedStatement_setDate(PreparedStatementProxy statement, int parameterIndex, java.sql.Date x, Calendar cal) + throws SQLException; - public void preparedStatement_setBlob(PreparedStatementProxy statement, int parameterIndex, Blob x) + void preparedStatement_setTime(PreparedStatementProxy statement, int parameterIndex, java.sql.Time x, Calendar cal) + throws SQLException; + + void preparedStatement_setTimestamp(PreparedStatementProxy statement, int parameterIndex, java.sql.Timestamp x, + Calendar cal) throws SQLException; + + void preparedStatement_setNull(PreparedStatementProxy statement, int parameterIndex, int sqlType, String typeName) + throws SQLException; + + void preparedStatement_setURL(PreparedStatementProxy statement, int parameterIndex, java.net.URL x) throws SQLException; - public void preparedStatement_setClob(PreparedStatementProxy statement, int parameterIndex, Clob x) - throws SQLException; + ParameterMetaData preparedStatement_getParameterMetaData(PreparedStatementProxy statement) throws SQLException; - public void preparedStatement_setArray(PreparedStatementProxy statement, int parameterIndex, Array x) + void preparedStatement_setRowId(PreparedStatementProxy statement, int parameterIndex, RowId x) throws SQLException; + + void preparedStatement_setNString(PreparedStatementProxy statement, int parameterIndex, String value) throws SQLException; - public ResultSetMetaData preparedStatement_getMetaData(PreparedStatementProxy statement) throws SQLException; + void preparedStatement_setNCharacterStream(PreparedStatementProxy statement, int parameterIndex, Reader value, + long length) throws SQLException; - public void preparedStatement_setDate(PreparedStatementProxy statement, int parameterIndex, java.sql.Date x, - Calendar cal) throws SQLException; + void preparedStatement_setNClob(PreparedStatementProxy statement, int parameterIndex, NClob value) + throws SQLException; - public void preparedStatement_setTime(PreparedStatementProxy statement, int parameterIndex, java.sql.Time x, - Calendar cal) throws SQLException; + void preparedStatement_setClob(PreparedStatementProxy statement, int parameterIndex, Reader reader, long length) + throws SQLException; - public void preparedStatement_setTimestamp(PreparedStatementProxy statement, int parameterIndex, - java.sql.Timestamp x, Calendar cal) throws SQLException; + void preparedStatement_setBlob(PreparedStatementProxy statement, int parameterIndex, InputStream inputStream, + long length) throws SQLException; - public void preparedStatement_setNull(PreparedStatementProxy statement, int parameterIndex, int sqlType, - String typeName) throws SQLException; + void preparedStatement_setNClob(PreparedStatementProxy statement, int parameterIndex, Reader reader, long length) + throws SQLException; - public void preparedStatement_setURL(PreparedStatementProxy statement, int parameterIndex, java.net.URL x) - throws SQLException; + void preparedStatement_setSQLXML(PreparedStatementProxy statement, int parameterIndex, SQLXML xmlObject) + throws SQLException; - public ParameterMetaData preparedStatement_getParameterMetaData(PreparedStatementProxy statement) - throws SQLException; + void preparedStatement_setObject(PreparedStatementProxy statement, int parameterIndex, Object x, int targetSqlType, + int scaleOrLength) throws SQLException; - public void preparedStatement_setRowId(PreparedStatementProxy statement, int parameterIndex, RowId x) - throws SQLException; - - public void preparedStatement_setNString(PreparedStatementProxy statement, int parameterIndex, String value) - throws SQLException; - - public void preparedStatement_setNCharacterStream(PreparedStatementProxy statement, int parameterIndex, - Reader value, long length) throws SQLException; - - public void preparedStatement_setNClob(PreparedStatementProxy statement, int parameterIndex, NClob value) - throws SQLException; - - public void preparedStatement_setClob(PreparedStatementProxy statement, int parameterIndex, Reader reader, + void preparedStatement_setAsciiStream(PreparedStatementProxy statement, int parameterIndex, java.io.InputStream x, long length) throws SQLException; - public void preparedStatement_setBlob(PreparedStatementProxy statement, int parameterIndex, - InputStream inputStream, long length) throws SQLException; - - public void preparedStatement_setNClob(PreparedStatementProxy statement, int parameterIndex, Reader reader, + void preparedStatement_setBinaryStream(PreparedStatementProxy statement, int parameterIndex, java.io.InputStream x, long length) throws SQLException; - public void preparedStatement_setSQLXML(PreparedStatementProxy statement, int parameterIndex, SQLXML xmlObject) - throws SQLException; + void preparedStatement_setCharacterStream(PreparedStatementProxy statement, int parameterIndex, + java.io.Reader reader, long length) throws SQLException; - public void preparedStatement_setObject(PreparedStatementProxy statement, int parameterIndex, Object x, - int targetSqlType, int scaleOrLength) throws SQLException; + void preparedStatement_setAsciiStream(PreparedStatementProxy statement, int parameterIndex, java.io.InputStream x) + throws SQLException; - public void preparedStatement_setAsciiStream(PreparedStatementProxy statement, int parameterIndex, - java.io.InputStream x, long length) throws SQLException; + void preparedStatement_setBinaryStream(PreparedStatementProxy statement, int parameterIndex, java.io.InputStream x) + throws SQLException; - public void preparedStatement_setBinaryStream(PreparedStatementProxy statement, int parameterIndex, - java.io.InputStream x, long length) throws SQLException; + void preparedStatement_setCharacterStream(PreparedStatementProxy statement, int parameterIndex, + java.io.Reader reader) throws SQLException; - public void preparedStatement_setCharacterStream(PreparedStatementProxy statement, int parameterIndex, - java.io.Reader reader, long length) throws SQLException; + void preparedStatement_setNCharacterStream(PreparedStatementProxy statement, int parameterIndex, Reader value) + throws SQLException; - public void preparedStatement_setAsciiStream(PreparedStatementProxy statement, int parameterIndex, - java.io.InputStream x) throws SQLException; + void preparedStatement_setClob(PreparedStatementProxy statement, int parameterIndex, Reader reader) + throws SQLException; - public void preparedStatement_setBinaryStream(PreparedStatementProxy statement, int parameterIndex, - java.io.InputStream x) throws SQLException; + void preparedStatement_setBlob(PreparedStatementProxy statement, int parameterIndex, InputStream inputStream) + throws SQLException; - public void preparedStatement_setCharacterStream(PreparedStatementProxy statement, int parameterIndex, - java.io.Reader reader) throws SQLException; - - public void preparedStatement_setNCharacterStream(PreparedStatementProxy statement, int parameterIndex, Reader value) - throws SQLException; - - public void preparedStatement_setClob(PreparedStatementProxy statement, int parameterIndex, Reader reader) - throws SQLException; - - public void preparedStatement_setBlob(PreparedStatementProxy statement, int parameterIndex, InputStream inputStream) - throws SQLException; - - public void preparedStatement_setNClob(PreparedStatementProxy statement, int parameterIndex, Reader reader) - throws SQLException; + void preparedStatement_setNClob(PreparedStatementProxy statement, int parameterIndex, Reader reader) + throws SQLException; // ///////////////////////////// - public void callableStatement_registerOutParameter(CallableStatementProxy statement, int parameterIndex, int sqlType) + void callableStatement_registerOutParameter(CallableStatementProxy statement, int parameterIndex, int sqlType) + throws SQLException; + + void callableStatement_registerOutParameter(CallableStatementProxy statement, int parameterIndex, int sqlType, + int scale) throws SQLException; + + boolean callableStatement_wasNull(CallableStatementProxy statement) throws SQLException; + + String callableStatement_getString(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + boolean callableStatement_getBoolean(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + byte callableStatement_getByte(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + short callableStatement_getShort(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + int callableStatement_getInt(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + long callableStatement_getLong(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + float callableStatement_getFloat(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + double callableStatement_getDouble(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + BigDecimal callableStatement_getBigDecimal(CallableStatementProxy statement, int parameterIndex, int scale) + throws SQLException; + + byte[] callableStatement_getBytes(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + java.sql.Date callableStatement_getDate(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + java.sql.Time callableStatement_getTime(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + java.sql.Timestamp callableStatement_getTimestamp(CallableStatementProxy statement, int parameterIndex) + throws SQLException; + + Object callableStatement_getObject(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + BigDecimal callableStatement_getBigDecimal(CallableStatementProxy statement, int parameterIndex) + throws SQLException; + + Object callableStatement_getObject(CallableStatementProxy statement, int parameterIndex, + java.util.Map> map) throws SQLException; + + Ref callableStatement_getRef(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + Blob callableStatement_getBlob(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + Clob callableStatement_getClob(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + Array callableStatement_getArray(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + java.sql.Date callableStatement_getDate(CallableStatementProxy statement, int parameterIndex, Calendar cal) + throws SQLException; + + java.sql.Time callableStatement_getTime(CallableStatementProxy statement, int parameterIndex, Calendar cal) + throws SQLException; + + java.sql.Timestamp callableStatement_getTimestamp(CallableStatementProxy statement, int parameterIndex, Calendar cal) throws SQLException; - public void callableStatement_registerOutParameter(CallableStatementProxy statement, int parameterIndex, - int sqlType, int scale) throws SQLException; + void callableStatement_registerOutParameter(CallableStatementProxy statement, int parameterIndex, int sqlType, + String typeName) throws SQLException; - public boolean callableStatement_wasNull(CallableStatementProxy statement) throws SQLException; + void callableStatement_registerOutParameter(CallableStatementProxy statement, String parameterName, int sqlType) + throws SQLException; - public String callableStatement_getString(CallableStatementProxy statement, int parameterIndex) throws SQLException; + void callableStatement_registerOutParameter(CallableStatementProxy statement, String parameterName, int sqlType, + int scale) throws SQLException; - public boolean callableStatement_getBoolean(CallableStatementProxy statement, int parameterIndex) - throws SQLException; + void callableStatement_registerOutParameter(CallableStatementProxy statement, String parameterName, int sqlType, + String typeName) throws SQLException; - public byte callableStatement_getByte(CallableStatementProxy statement, int parameterIndex) throws SQLException; + java.net.URL callableStatement_getURL(CallableStatementProxy statement, int parameterIndex) throws SQLException; - public short callableStatement_getShort(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public int callableStatement_getInt(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public long callableStatement_getLong(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public float callableStatement_getFloat(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public double callableStatement_getDouble(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public BigDecimal callableStatement_getBigDecimal(CallableStatementProxy statement, int parameterIndex, int scale) - throws SQLException; - - public byte[] callableStatement_getBytes(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public java.sql.Date callableStatement_getDate(CallableStatementProxy statement, int parameterIndex) - throws SQLException; - - public java.sql.Time callableStatement_getTime(CallableStatementProxy statement, int parameterIndex) - throws SQLException; - - public java.sql.Timestamp callableStatement_getTimestamp(CallableStatementProxy statement, int parameterIndex) - throws SQLException; - - public Object callableStatement_getObject(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public BigDecimal callableStatement_getBigDecimal(CallableStatementProxy statement, int parameterIndex) + void callableStatement_setURL(CallableStatementProxy statement, String parameterName, java.net.URL val) throws SQLException; - public Object callableStatement_getObject(CallableStatementProxy statement, int parameterIndex, - java.util.Map> map) throws SQLException; + void callableStatement_setNull(CallableStatementProxy statement, String parameterName, int sqlType) + throws SQLException; - public Ref callableStatement_getRef(CallableStatementProxy statement, int parameterIndex) throws SQLException; + void callableStatement_setBoolean(CallableStatementProxy statement, String parameterName, boolean x) + throws SQLException; - public Blob callableStatement_getBlob(CallableStatementProxy statement, int parameterIndex) throws SQLException; + void callableStatement_setByte(CallableStatementProxy statement, String parameterName, byte x) throws SQLException; - public Clob callableStatement_getClob(CallableStatementProxy statement, int parameterIndex) throws SQLException; + void callableStatement_setShort(CallableStatementProxy statement, String parameterName, short x) + throws SQLException; - public Array callableStatement_getArray(CallableStatementProxy statement, int parameterIndex) throws SQLException; + void callableStatement_setInt(CallableStatementProxy statement, String parameterName, int x) throws SQLException; - public java.sql.Date callableStatement_getDate(CallableStatementProxy statement, int parameterIndex, Calendar cal) - throws SQLException; + void callableStatement_setLong(CallableStatementProxy statement, String parameterName, long x) throws SQLException; - public java.sql.Time callableStatement_getTime(CallableStatementProxy statement, int parameterIndex, Calendar cal) - throws SQLException; + void callableStatement_setFloat(CallableStatementProxy statement, String parameterName, float x) + throws SQLException; - public java.sql.Timestamp callableStatement_getTimestamp(CallableStatementProxy statement, int parameterIndex, - Calendar cal) throws SQLException; - - public void callableStatement_registerOutParameter(CallableStatementProxy statement, int parameterIndex, - int sqlType, String typeName) throws SQLException; - - public void callableStatement_registerOutParameter(CallableStatementProxy statement, String parameterName, - int sqlType) throws SQLException; - - public void callableStatement_registerOutParameter(CallableStatementProxy statement, String parameterName, - int sqlType, int scale) throws SQLException; - - public void callableStatement_registerOutParameter(CallableStatementProxy statement, String parameterName, - int sqlType, String typeName) throws SQLException; - - public java.net.URL callableStatement_getURL(CallableStatementProxy statement, int parameterIndex) + void callableStatement_setDouble(CallableStatementProxy statement, String parameterName, double x) throws SQLException; - public void callableStatement_setURL(CallableStatementProxy statement, String parameterName, java.net.URL val) - throws SQLException; - - public void callableStatement_setNull(CallableStatementProxy statement, String parameterName, int sqlType) + void callableStatement_setBigDecimal(CallableStatementProxy statement, String parameterName, BigDecimal x) throws SQLException; - public void callableStatement_setBoolean(CallableStatementProxy statement, String parameterName, boolean x) - throws SQLException; - - public void callableStatement_setByte(CallableStatementProxy statement, String parameterName, byte x) - throws SQLException; - - public void callableStatement_setShort(CallableStatementProxy statement, String parameterName, short x) - throws SQLException; - - public void callableStatement_setInt(CallableStatementProxy statement, String parameterName, int x) - throws SQLException; - - public void callableStatement_setLong(CallableStatementProxy statement, String parameterName, long x) - throws SQLException; - - public void callableStatement_setFloat(CallableStatementProxy statement, String parameterName, float x) - throws SQLException; - - public void callableStatement_setDouble(CallableStatementProxy statement, String parameterName, double x) - throws SQLException; - - public void callableStatement_setBigDecimal(CallableStatementProxy statement, String parameterName, BigDecimal x) - throws SQLException; - - public void callableStatement_setString(CallableStatementProxy statement, String parameterName, String x) - throws SQLException; - - public void callableStatement_setBytes(CallableStatementProxy statement, String parameterName, byte x[]) - throws SQLException; - - public void callableStatement_setDate(CallableStatementProxy statement, String parameterName, java.sql.Date x) - throws SQLException; - - public void callableStatement_setTime(CallableStatementProxy statement, String parameterName, java.sql.Time x) - throws SQLException; - - public void callableStatement_setTimestamp(CallableStatementProxy statement, String parameterName, - java.sql.Timestamp x) throws SQLException; - - public void callableStatement_setAsciiStream(CallableStatementProxy statement, String parameterName, - java.io.InputStream x, int length) throws SQLException; - - public void callableStatement_setBinaryStream(CallableStatementProxy statement, String parameterName, - java.io.InputStream x, int length) throws SQLException; - - public void callableStatement_setObject(CallableStatementProxy statement, String parameterName, Object x, - int targetSqlType, int scale) throws SQLException; - - public void callableStatement_setObject(CallableStatementProxy statement, String parameterName, Object x, - int targetSqlType) throws SQLException; - - public void callableStatement_setObject(CallableStatementProxy statement, String parameterName, Object x) - throws SQLException; - - public void callableStatement_setCharacterStream(CallableStatementProxy statement, String parameterName, - java.io.Reader reader, int length) throws SQLException; - - public void callableStatement_setDate(CallableStatementProxy statement, String parameterName, java.sql.Date x, - Calendar cal) throws SQLException; - - public void callableStatement_setTime(CallableStatementProxy statement, String parameterName, java.sql.Time x, - Calendar cal) throws SQLException; - - public void callableStatement_setTimestamp(CallableStatementProxy statement, String parameterName, - java.sql.Timestamp x, Calendar cal) throws SQLException; - - public void callableStatement_setNull(CallableStatementProxy statement, String parameterName, int sqlType, - String typeName) throws SQLException; - - public String callableStatement_getString(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public boolean callableStatement_getBoolean(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public byte callableStatement_getByte(CallableStatementProxy statement, String parameterName) throws SQLException; - - public short callableStatement_getShort(CallableStatementProxy statement, String parameterName) throws SQLException; - - public int callableStatement_getInt(CallableStatementProxy statement, String parameterName) throws SQLException; - - public long callableStatement_getLong(CallableStatementProxy statement, String parameterName) throws SQLException; - - public float callableStatement_getFloat(CallableStatementProxy statement, String parameterName) throws SQLException; - - public double callableStatement_getDouble(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public byte[] callableStatement_getBytes(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public java.sql.Date callableStatement_getDate(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public java.sql.Time callableStatement_getTime(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public java.sql.Timestamp callableStatement_getTimestamp(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public Object callableStatement_getObject(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public BigDecimal callableStatement_getBigDecimal(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public Object callableStatement_getObject(CallableStatementProxy statement, String parameterName, - java.util.Map> map) throws SQLException; - - public Ref callableStatement_getRef(CallableStatementProxy statement, String parameterName) throws SQLException; - - public Blob callableStatement_getBlob(CallableStatementProxy statement, String parameterName) throws SQLException; - - public Clob callableStatement_getClob(CallableStatementProxy statement, String parameterName) throws SQLException; - - public Array callableStatement_getArray(CallableStatementProxy statement, String parameterName) throws SQLException; - - public java.sql.Date callableStatement_getDate(CallableStatementProxy statement, String parameterName, Calendar cal) - throws SQLException; - - public java.sql.Time callableStatement_getTime(CallableStatementProxy statement, String parameterName, Calendar cal) - throws SQLException; - - public java.sql.Timestamp callableStatement_getTimestamp(CallableStatementProxy statement, String parameterName, - Calendar cal) throws SQLException; - - public java.net.URL callableStatement_getURL(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public RowId callableStatement_getRowId(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public RowId callableStatement_getRowId(CallableStatementProxy statement, String parameterName) throws SQLException; - - public void callableStatement_setRowId(CallableStatementProxy statement, String parameterName, RowId x) - throws SQLException; - - public void callableStatement_setNString(CallableStatementProxy statement, String parameterName, String value) - throws SQLException; - - public void callableStatement_setNCharacterStream(CallableStatementProxy statement, String parameterName, - Reader value, long length) throws SQLException; - - public void callableStatement_setNClob(CallableStatementProxy statement, String parameterName, NClob value) - throws SQLException; - - public void callableStatement_setClob(CallableStatementProxy statement, String parameterName, Reader reader, - long length) throws SQLException; - - public void callableStatement_setBlob(CallableStatementProxy statement, String parameterName, - InputStream inputStream, long length) throws SQLException; - - public void callableStatement_setNClob(CallableStatementProxy statement, String parameterName, Reader reader, - long length) throws SQLException; - - public NClob callableStatement_getNClob(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public NClob callableStatement_getNClob(CallableStatementProxy statement, String parameterName) throws SQLException; - - public void callableStatement_setSQLXML(CallableStatementProxy statement, String parameterName, SQLXML xmlObject) - throws SQLException; - - public SQLXML callableStatement_getSQLXML(CallableStatementProxy statement, int parameterIndex) throws SQLException; - - public SQLXML callableStatement_getSQLXML(CallableStatementProxy statement, String parameterName) - throws SQLException; - - public String callableStatement_getNString(CallableStatementProxy statement, int parameterIndex) - throws SQLException; - - public String callableStatement_getNString(CallableStatementProxy statement, String parameterName) + void callableStatement_setString(CallableStatementProxy statement, String parameterName, String x) throws SQLException; - public java.io.Reader callableStatement_getNCharacterStream(CallableStatementProxy statement, int parameterIndex) + void callableStatement_setBytes(CallableStatementProxy statement, String parameterName, byte x[]) + throws SQLException; + + void callableStatement_setDate(CallableStatementProxy statement, String parameterName, java.sql.Date x) + throws SQLException; + + void callableStatement_setTime(CallableStatementProxy statement, String parameterName, java.sql.Time x) + throws SQLException; + + void callableStatement_setTimestamp(CallableStatementProxy statement, String parameterName, java.sql.Timestamp x) throws SQLException; - public java.io.Reader callableStatement_getNCharacterStream(CallableStatementProxy statement, String parameterName) - throws SQLException; + void callableStatement_setAsciiStream(CallableStatementProxy statement, String parameterName, + java.io.InputStream x, int length) throws SQLException; - public java.io.Reader callableStatement_getCharacterStream(CallableStatementProxy statement, int parameterIndex) - throws SQLException; + void callableStatement_setBinaryStream(CallableStatementProxy statement, String parameterName, + java.io.InputStream x, int length) throws SQLException; - public java.io.Reader callableStatement_getCharacterStream(CallableStatementProxy statement, String parameterName) - throws SQLException; + void callableStatement_setObject(CallableStatementProxy statement, String parameterName, Object x, + int targetSqlType, int scale) throws SQLException; - public void callableStatement_setBlob(CallableStatementProxy statement, String parameterName, Blob x) - throws SQLException; + void callableStatement_setObject(CallableStatementProxy statement, String parameterName, Object x, int targetSqlType) + throws SQLException; - public void callableStatement_setClob(CallableStatementProxy statement, String parameterName, Clob x) - throws SQLException; + void callableStatement_setObject(CallableStatementProxy statement, String parameterName, Object x) + throws SQLException; - public void callableStatement_setAsciiStream(CallableStatementProxy statement, String parameterName, - java.io.InputStream x, long length) throws SQLException; + void callableStatement_setCharacterStream(CallableStatementProxy statement, String parameterName, + java.io.Reader reader, int length) throws SQLException; - public void callableStatement_setBinaryStream(CallableStatementProxy statement, String parameterName, - java.io.InputStream x, long length) throws SQLException; + void callableStatement_setDate(CallableStatementProxy statement, String parameterName, java.sql.Date x, Calendar cal) + throws SQLException; - public void callableStatement_setCharacterStream(CallableStatementProxy statement, String parameterName, - java.io.Reader reader, long length) throws SQLException; + void callableStatement_setTime(CallableStatementProxy statement, String parameterName, java.sql.Time x, Calendar cal) + throws SQLException; - public void callableStatement_setAsciiStream(CallableStatementProxy statement, String parameterName, - java.io.InputStream x) throws SQLException; + void callableStatement_setTimestamp(CallableStatementProxy statement, String parameterName, java.sql.Timestamp x, + Calendar cal) throws SQLException; - public void callableStatement_setBinaryStream(CallableStatementProxy statement, String parameterName, - java.io.InputStream x) throws SQLException; + void callableStatement_setNull(CallableStatementProxy statement, String parameterName, int sqlType, String typeName) + throws SQLException; - public void callableStatement_setCharacterStream(CallableStatementProxy statement, String parameterName, - java.io.Reader reader) throws SQLException; + String callableStatement_getString(CallableStatementProxy statement, String parameterName) throws SQLException; - public void callableStatement_setNCharacterStream(CallableStatementProxy statement, String parameterName, - Reader value) throws SQLException; + boolean callableStatement_getBoolean(CallableStatementProxy statement, String parameterName) throws SQLException; - public void callableStatement_setClob(CallableStatementProxy statement, String parameterName, Reader reader) - throws SQLException; + byte callableStatement_getByte(CallableStatementProxy statement, String parameterName) throws SQLException; - public void callableStatement_setBlob(CallableStatementProxy statement, String parameterName, - InputStream inputStream) throws SQLException; + short callableStatement_getShort(CallableStatementProxy statement, String parameterName) throws SQLException; - public void callableStatement_setNClob(CallableStatementProxy statement, String parameterName, Reader reader) + int callableStatement_getInt(CallableStatementProxy statement, String parameterName) throws SQLException; + + long callableStatement_getLong(CallableStatementProxy statement, String parameterName) throws SQLException; + + float callableStatement_getFloat(CallableStatementProxy statement, String parameterName) throws SQLException; + + double callableStatement_getDouble(CallableStatementProxy statement, String parameterName) throws SQLException; + + byte[] callableStatement_getBytes(CallableStatementProxy statement, String parameterName) throws SQLException; + + java.sql.Date callableStatement_getDate(CallableStatementProxy statement, String parameterName) throws SQLException; + + java.sql.Time callableStatement_getTime(CallableStatementProxy statement, String parameterName) throws SQLException; + + java.sql.Timestamp callableStatement_getTimestamp(CallableStatementProxy statement, String parameterName) + throws SQLException; + + Object callableStatement_getObject(CallableStatementProxy statement, String parameterName) throws SQLException; + + BigDecimal callableStatement_getBigDecimal(CallableStatementProxy statement, String parameterName) + throws SQLException; + + Object callableStatement_getObject(CallableStatementProxy statement, String parameterName, + java.util.Map> map) throws SQLException; + + Ref callableStatement_getRef(CallableStatementProxy statement, String parameterName) throws SQLException; + + Blob callableStatement_getBlob(CallableStatementProxy statement, String parameterName) throws SQLException; + + Clob callableStatement_getClob(CallableStatementProxy statement, String parameterName) throws SQLException; + + Array callableStatement_getArray(CallableStatementProxy statement, String parameterName) throws SQLException; + + java.sql.Date callableStatement_getDate(CallableStatementProxy statement, String parameterName, Calendar cal) throws SQLException; - public void clob_free(ClobProxy wrapper) throws SQLException; + java.sql.Time callableStatement_getTime(CallableStatementProxy statement, String parameterName, Calendar cal) + throws SQLException; - public InputStream clob_getAsciiStream(ClobProxy wrapper) throws SQLException; + java.sql.Timestamp callableStatement_getTimestamp(CallableStatementProxy statement, String parameterName, + Calendar cal) throws SQLException; - public Reader clob_getCharacterStream(ClobProxy wrapper) throws SQLException; + java.net.URL callableStatement_getURL(CallableStatementProxy statement, String parameterName) throws SQLException; - public Reader clob_getCharacterStream(ClobProxy wrapper, long pos, long length) throws SQLException; + RowId callableStatement_getRowId(CallableStatementProxy statement, int parameterIndex) throws SQLException; - public String clob_getSubString(ClobProxy wrapper, long pos, int length) throws SQLException; + RowId callableStatement_getRowId(CallableStatementProxy statement, String parameterName) throws SQLException; - public long clob_length(ClobProxy wrapper) throws SQLException; + void callableStatement_setRowId(CallableStatementProxy statement, String parameterName, RowId x) + throws SQLException; - public long clob_position(ClobProxy wrapper, String searchstr, long start) throws SQLException; + void callableStatement_setNString(CallableStatementProxy statement, String parameterName, String value) + throws SQLException; - public long clob_position(ClobProxy wrapper, Clob searchstr, long start) throws SQLException; + void callableStatement_setNCharacterStream(CallableStatementProxy statement, String parameterName, Reader value, + long length) throws SQLException; - public OutputStream clob_setAsciiStream(ClobProxy wrapper, long pos) throws SQLException; + void callableStatement_setNClob(CallableStatementProxy statement, String parameterName, NClob value) + throws SQLException; - public Writer clob_setCharacterStream(ClobProxy wrapper, long pos) throws SQLException; + void callableStatement_setClob(CallableStatementProxy statement, String parameterName, Reader reader, long length) + throws SQLException; - public int clob_setString(ClobProxy wrapper, long pos, String str) throws SQLException; + void callableStatement_setBlob(CallableStatementProxy statement, String parameterName, InputStream inputStream, + long length) throws SQLException; - public int clob_setString(ClobProxy wrapper, long pos, String str, int offset, int len) throws SQLException; + void callableStatement_setNClob(CallableStatementProxy statement, String parameterName, Reader reader, long length) + throws SQLException; - public void clob_truncate(ClobProxy wrapper, long len) throws SQLException; + NClob callableStatement_getNClob(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + NClob callableStatement_getNClob(CallableStatementProxy statement, String parameterName) throws SQLException; + + void callableStatement_setSQLXML(CallableStatementProxy statement, String parameterName, SQLXML xmlObject) + throws SQLException; + + SQLXML callableStatement_getSQLXML(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + SQLXML callableStatement_getSQLXML(CallableStatementProxy statement, String parameterName) throws SQLException; + + String callableStatement_getNString(CallableStatementProxy statement, int parameterIndex) throws SQLException; + + String callableStatement_getNString(CallableStatementProxy statement, String parameterName) throws SQLException; + + java.io.Reader callableStatement_getNCharacterStream(CallableStatementProxy statement, int parameterIndex) + throws SQLException; + + java.io.Reader callableStatement_getNCharacterStream(CallableStatementProxy statement, String parameterName) + throws SQLException; + + java.io.Reader callableStatement_getCharacterStream(CallableStatementProxy statement, int parameterIndex) + throws SQLException; + + java.io.Reader callableStatement_getCharacterStream(CallableStatementProxy statement, String parameterName) + throws SQLException; + + void callableStatement_setBlob(CallableStatementProxy statement, String parameterName, Blob x) throws SQLException; + + void callableStatement_setClob(CallableStatementProxy statement, String parameterName, Clob x) throws SQLException; + + void callableStatement_setAsciiStream(CallableStatementProxy statement, String parameterName, + java.io.InputStream x, long length) throws SQLException; + + void callableStatement_setBinaryStream(CallableStatementProxy statement, String parameterName, + java.io.InputStream x, long length) throws SQLException; + + void callableStatement_setCharacterStream(CallableStatementProxy statement, String parameterName, + java.io.Reader reader, long length) throws SQLException; + + void callableStatement_setAsciiStream(CallableStatementProxy statement, String parameterName, java.io.InputStream x) + throws SQLException; + + void callableStatement_setBinaryStream(CallableStatementProxy statement, String parameterName, java.io.InputStream x) + throws SQLException; + + void callableStatement_setCharacterStream(CallableStatementProxy statement, String parameterName, + java.io.Reader reader) throws SQLException; + + void callableStatement_setNCharacterStream(CallableStatementProxy statement, String parameterName, Reader value) + throws SQLException; + + void callableStatement_setClob(CallableStatementProxy statement, String parameterName, Reader reader) + throws SQLException; + + void callableStatement_setBlob(CallableStatementProxy statement, String parameterName, InputStream inputStream) + throws SQLException; + + void callableStatement_setNClob(CallableStatementProxy statement, String parameterName, Reader reader) + throws SQLException; + + void clob_free(ClobProxy wrapper) throws SQLException; + + InputStream clob_getAsciiStream(ClobProxy wrapper) throws SQLException; + + Reader clob_getCharacterStream(ClobProxy wrapper) throws SQLException; + + Reader clob_getCharacterStream(ClobProxy wrapper, long pos, long length) throws SQLException; + + String clob_getSubString(ClobProxy wrapper, long pos, int length) throws SQLException; + + long clob_length(ClobProxy wrapper) throws SQLException; + + long clob_position(ClobProxy wrapper, String searchstr, long start) throws SQLException; + + long clob_position(ClobProxy wrapper, Clob searchstr, long start) throws SQLException; + + OutputStream clob_setAsciiStream(ClobProxy wrapper, long pos) throws SQLException; + + Writer clob_setCharacterStream(ClobProxy wrapper, long pos) throws SQLException; + + int clob_setString(ClobProxy wrapper, long pos, String str) throws SQLException; + + int clob_setString(ClobProxy wrapper, long pos, String str, int offset, int len) throws SQLException; + + void clob_truncate(ClobProxy wrapper, long len) throws SQLException; // //// diff --git a/src/main/java/com/alibaba/druid/filter/FilterEventAdapter.java b/src/main/java/com/alibaba/druid/filter/FilterEventAdapter.java index 2e7585cd25..b96ff057d9 100644 --- a/src/main/java/com/alibaba/druid/filter/FilterEventAdapter.java +++ b/src/main/java/com/alibaba/druid/filter/FilterEventAdapter.java @@ -301,8 +301,10 @@ public abstract class FilterEventAdapter extends FilterAdapter { try { ResultSetProxy resultSet = super.statement_executeQuery(chain, statement, sql); - statementExecuteQueryAfter(statement, sql, resultSet); - resultSetOpenAfter(resultSet); + if (resultSet != null) { + statementExecuteQueryAfter(statement, sql, resultSet); + resultSetOpenAfter(resultSet); + } return resultSet; } catch (SQLException error) { @@ -462,9 +464,11 @@ public abstract class FilterEventAdapter extends FilterAdapter { ResultSetProxy resultSet = chain.preparedStatement_executeQuery(statement); - statementExecuteQueryAfter(statement, statement.getSql(), resultSet); + if (resultSet != null) { + statementExecuteQueryAfter(statement, statement.getSql(), resultSet); - resultSetOpenAfter(resultSet); + resultSetOpenAfter(resultSet); + } return resultSet; } catch (SQLException error) { diff --git a/src/main/java/com/alibaba/druid/filter/config/ConfigFilter.java b/src/main/java/com/alibaba/druid/filter/config/ConfigFilter.java index cf6820566d..7f06391442 100644 --- a/src/main/java/com/alibaba/druid/filter/config/ConfigFilter.java +++ b/src/main/java/com/alibaba/druid/filter/config/ConfigFilter.java @@ -73,7 +73,7 @@ public class ConfigFilter extends FilterAdapter { return algorithm; } - public void setAlgorithm(String algorithm) { + public final void setAlgorithm(String algorithm) { this.algorithm = algorithm; try { this.cipher = Cipher.getInstance(algorithm); @@ -86,7 +86,7 @@ public class ConfigFilter extends FilterAdapter { return encryptedPassword; } - public void setEncryptedPassword(String encryptedPassword) { + public final void setEncryptedPassword(String encryptedPassword) { this.encryptedPassword = encryptedPassword; } @@ -94,7 +94,7 @@ public class ConfigFilter extends FilterAdapter { return key; } - public void setKey(String key) { + public final void setKey(String key) { this.key = key; byte[] bytes = Base64.base64ToByteArray(key); diff --git a/src/main/java/com/alibaba/druid/filter/encoding/CharsetConvert.java b/src/main/java/com/alibaba/druid/filter/encoding/CharsetConvert.java index fec7c35567..de21e7cf49 100644 --- a/src/main/java/com/alibaba/druid/filter/encoding/CharsetConvert.java +++ b/src/main/java/com/alibaba/druid/filter/encoding/CharsetConvert.java @@ -73,11 +73,7 @@ public class CharsetConvert { * @return boolean */ public boolean isEmpty(String s) { - if (s == null || "".equals(s)) { - return true; - } else { - return false; - } + return s == null || "".equals(s); } } diff --git a/src/main/java/com/alibaba/druid/filter/encoding/EncodingConvertFilter.java b/src/main/java/com/alibaba/druid/filter/encoding/EncodingConvertFilter.java index 75af4b7979..96a5428ce0 100644 --- a/src/main/java/com/alibaba/druid/filter/encoding/EncodingConvertFilter.java +++ b/src/main/java/com/alibaba/druid/filter/encoding/EncodingConvertFilter.java @@ -26,8 +26,6 @@ import java.util.Properties; import com.alibaba.druid.filter.FilterAdapter; import com.alibaba.druid.filter.FilterChain; -import com.alibaba.druid.proxy.config.AbstractDruidFilterConfig; -import com.alibaba.druid.proxy.config.EncodingDruidFilterConfig; import com.alibaba.druid.proxy.jdbc.CallableStatementProxy; import com.alibaba.druid.proxy.jdbc.ClobProxy; import com.alibaba.druid.proxy.jdbc.ConnectionProxy; @@ -46,14 +44,6 @@ public class EncodingConvertFilter extends FilterAdapter { private String clientEncoding; private String serverEncoding; - public void loadConfig(AbstractDruidFilterConfig druidFilterConfig) { - EncodingDruidFilterConfig druidEncodingFilterConfig = (EncodingDruidFilterConfig) druidFilterConfig; - if (druidEncodingFilterConfig != null) { - clientEncoding = druidEncodingFilterConfig.getClientEncoding(); - serverEncoding = druidEncodingFilterConfig.getServerEncoding(); - } - } - public ConnectionProxy connection_connect(FilterChain chain, Properties info) throws SQLException { ConnectionProxy conn = chain.connection_connect(info); @@ -233,7 +223,7 @@ public class EncodingConvertFilter extends FilterAdapter { return charsetConvert.encode(s); } catch (UnsupportedEncodingException e) { - throw new SQLException(e.getMessage()); + throw new SQLException(e.getMessage(), e); } } @@ -242,7 +232,7 @@ public class EncodingConvertFilter extends FilterAdapter { CharsetConvert charsetConvert = (CharsetConvert) connection.getAttributes().get(ATTR_CHARSET_CONVERTER); return charsetConvert.decode(s); } catch (UnsupportedEncodingException e) { - throw new SQLException(e.getMessage()); + throw new SQLException(e.getMessage(), e); } } diff --git a/src/main/java/com/alibaba/druid/filter/stat/StatFilter.java b/src/main/java/com/alibaba/druid/filter/stat/StatFilter.java index 3562700a5c..7af7ba5012 100644 --- a/src/main/java/com/alibaba/druid/filter/stat/StatFilter.java +++ b/src/main/java/com/alibaba/druid/filter/stat/StatFilter.java @@ -16,6 +16,7 @@ package com.alibaba.druid.filter.stat; import java.io.InputStream; +import java.io.Reader; import java.sql.Blob; import java.sql.Clob; import java.sql.NClob; @@ -23,7 +24,6 @@ import java.sql.SQLException; import java.sql.Savepoint; import java.util.Date; import java.util.Properties; -import java.util.concurrent.atomic.AtomicLong; import com.alibaba.druid.filter.Filter; import com.alibaba.druid.filter.FilterChain; @@ -78,8 +78,6 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { private boolean connectionStackTraceEnable = false; - protected final AtomicLong resetCount = new AtomicLong(); - // 3 seconds is slow sql protected long slowSqlMillis = 3 * 1000; @@ -112,10 +110,6 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { this.connectionStackTraceEnable = connectionStackTraceEnable; } - public long getResetCount() { - return resetCount.get(); - } - public boolean isMergeSql() { return mergeSql; } @@ -507,7 +501,7 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (index != 0) { out.writeComma(); } - + Object value = parameter.getValue(); if (value == null) { out.writeNull(); @@ -573,6 +567,18 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { sqlStat.addFetchRowCount(fetchRowCount); long stmtExecuteNano = resultSet.getStatementProxy().getLastExecuteTimeNano(); sqlStat.addResultSetHoldTimeNano(stmtExecuteNano, nanos); + if (resultSet.getReadStringLength() > 0) { + sqlStat.addStringReadLength(resultSet.getReadStringLength()); + } + if (resultSet.getReadBytesLength() > 0) { + sqlStat.addReadBytesLength(resultSet.getReadBytesLength()); + } + if (resultSet.getOpenInputStreamCount() > 0) { + sqlStat.addInputStreamOpenCount(resultSet.getOpenInputStreamCount()); + } + if (resultSet.getOpenReaderCount() > 0) { + sqlStat.addReaderOpenCount(resultSet.getOpenReaderCount()); + } } } @@ -685,6 +691,52 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { return clob; } + @Override + public Blob callableStatement_getBlob(FilterChain chain, CallableStatementProxy statement, int parameterIndex) + throws SQLException { + Blob blob = chain.callableStatement_getBlob(statement, parameterIndex); + + if (blob != null) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, blob); + } + + return blob; + } + + @Override + public Blob callableStatement_getBlob(FilterChain chain, CallableStatementProxy statement, String parameterName) + throws SQLException { + Blob blob = chain.callableStatement_getBlob(statement, parameterName); + + if (blob != null) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, blob); + } + + return blob; + } + + @Override + public Blob resultSet_getBlob(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException { + Blob blob = chain.resultSet_getBlob(result, columnIndex); + + if (blob != null) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, blob); + } + + return blob; + } + + @Override + public Blob resultSet_getBlob(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException { + Blob blob = chain.resultSet_getBlob(result, columnLabel); + + if (blob != null) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, blob); + } + + return blob; + } + @Override public Clob callableStatement_getClob(FilterChain chain, CallableStatementProxy statement, int parameterIndex) throws SQLException { @@ -715,6 +767,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (obj instanceof Clob) { clobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (ClobProxy) obj); + } else if (obj instanceof Blob) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (Blob) obj); + } else if (obj instanceof String) { + result.addReadStringLength(((String) obj).length()); } return obj; @@ -727,6 +783,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (obj instanceof Clob) { clobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (ClobProxy) obj); + } else if (obj instanceof Blob) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (Blob) obj); + } else if (obj instanceof String) { + result.addReadStringLength(((String) obj).length()); } return obj; @@ -738,6 +798,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (obj instanceof Clob) { clobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (ClobProxy) obj); + } else if (obj instanceof Blob) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (Blob) obj); + } else if (obj instanceof String) { + result.addReadStringLength(((String) obj).length()); } return obj; @@ -750,6 +814,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (obj instanceof Clob) { clobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (ClobProxy) obj); + } else if (obj instanceof Blob) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), result, (Blob) obj); + } else if (obj instanceof String) { + result.addReadStringLength(((String) obj).length()); } return obj; @@ -762,6 +830,8 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (obj instanceof Clob) { clobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (ClobProxy) obj); + } else if (obj instanceof Blob) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (Blob) obj); } return obj; @@ -774,6 +844,8 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (obj instanceof Clob) { clobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (ClobProxy) obj); + } else if (obj instanceof Blob) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (Blob) obj); } return obj; @@ -786,6 +858,8 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (obj instanceof Clob) { clobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (ClobProxy) obj); + } else if (obj instanceof Blob) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (Blob) obj); } return obj; @@ -799,15 +873,34 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { if (obj instanceof Clob) { clobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (ClobProxy) obj); + } else if (obj instanceof Blob) { + blobOpenAfter(chain.getDataSource().getDataSourceStat(), statement, (Blob) obj); } return obj; } + private void blobOpenAfter(JdbcDataSourceStat dataSourceStat, ResultSetProxy rs, Blob blob) { + blobOpenAfter(dataSourceStat, rs.getStatementProxy(), blob); + } + private void clobOpenAfter(JdbcDataSourceStat dataSourceStat, ResultSetProxy rs, ClobProxy clob) { clobOpenAfter(dataSourceStat, rs.getStatementProxy(), clob); } + private void blobOpenAfter(JdbcDataSourceStat dataSourceStat, StatementProxy stmt, Blob blob) { + dataSourceStat.incrementBlobOpenCount(); + + if (stmt != null) { + JdbcSqlStat sqlStat = stmt.getSqlStat(); + if (sqlStat != null) { + sqlStat.incrementBlobOpenCount(); + } + } + + StatFilterContext.getInstance().blob_open(); + } + private void clobOpenAfter(JdbcDataSourceStat dataSourceStat, StatementProxy stmt, ClobProxy clob) { dataSourceStat.incrementClobOpenCount(); @@ -820,4 +913,120 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean { StatFilterContext.getInstance().clob_open(); } + + @Override + public String resultSet_getString(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException { + String value = chain.resultSet_getString(result, columnIndex); + + if (value != null) { + result.addReadStringLength(value.length()); + } + + return value; + } + + @Override + public String resultSet_getString(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException { + String value = chain.resultSet_getString(result, columnLabel); + + if (value != null) { + result.addReadStringLength(value.length()); + } + + return value; + } + + @Override + public byte[] resultSet_getBytes(FilterChain chain, ResultSetProxy result, int columnIndex) throws SQLException { + byte[] value = chain.resultSet_getBytes(result, columnIndex); + + if (value != null) { + result.addReadBytesLength(value.length); + } + + return value; + } + + @Override + public byte[] resultSet_getBytes(FilterChain chain, ResultSetProxy result, String columnLabel) throws SQLException { + byte[] value = chain.resultSet_getBytes(result, columnLabel); + + if (value != null) { + result.addReadBytesLength(value.length); + } + + return value; + } + + @Override + public InputStream resultSet_getBinaryStream(FilterChain chain, ResultSetProxy result, int columnIndex) + throws SQLException { + InputStream input = chain.resultSet_getBinaryStream(result, columnIndex); + + if (input != null) { + result.incrementOpenInputStreamCount(); + } + + return input; + } + + @Override + public InputStream resultSet_getBinaryStream(FilterChain chain, ResultSetProxy result, String columnLabel) + throws SQLException { + InputStream input = chain.resultSet_getBinaryStream(result, columnLabel); + + if (input != null) { + result.incrementOpenInputStreamCount(); + } + + return input; + } + + @Override + public InputStream resultSet_getAsciiStream(FilterChain chain, ResultSetProxy result, int columnIndex) + throws SQLException { + InputStream input = chain.resultSet_getAsciiStream(result, columnIndex); + + if (input != null) { + result.incrementOpenInputStreamCount(); + } + + return input; + } + + @Override + public InputStream resultSet_getAsciiStream(FilterChain chain, ResultSetProxy result, String columnLabel) + throws SQLException { + InputStream input = chain.resultSet_getAsciiStream(result, columnLabel); + + if (input != null) { + result.incrementOpenInputStreamCount(); + } + + return input; + } + + @Override + public Reader resultSet_getCharacterStream(FilterChain chain, ResultSetProxy result, int columnIndex) + throws SQLException { + Reader reader = chain.resultSet_getCharacterStream(result, columnIndex); + + if (reader != null) { + result.incrementOpenReaderCount(); + } + + return reader; + } + + @Override + public Reader resultSet_getCharacterStream(FilterChain chain, ResultSetProxy result, String columnLabel) + throws SQLException { + Reader reader = chain.resultSet_getCharacterStream(result, columnLabel); + + if (reader != null) { + result.incrementOpenReaderCount(); + } + + return reader; + } } diff --git a/src/main/java/com/alibaba/druid/filter/stat/StatFilterContext.java b/src/main/java/com/alibaba/druid/filter/stat/StatFilterContext.java index ab3162abcc..97c84d5f89 100644 --- a/src/main/java/com/alibaba/druid/filter/stat/StatFilterContext.java +++ b/src/main/java/com/alibaba/druid/filter/stat/StatFilterContext.java @@ -130,11 +130,12 @@ public class StatFilterContext { listener.clob_open(); } } - - public void clob_free() { + + public void blob_open() { for (int i = 0; i < listeners.size(); ++i) { StatFilterContextListener listener = listeners.get(i); - listener.clob_free(); + listener.blob_open(); } } + } diff --git a/src/main/java/com/alibaba/druid/filter/stat/StatFilterContextListener.java b/src/main/java/com/alibaba/druid/filter/stat/StatFilterContextListener.java index 218c24e229..2960431ca7 100644 --- a/src/main/java/com/alibaba/druid/filter/stat/StatFilterContextListener.java +++ b/src/main/java/com/alibaba/druid/filter/stat/StatFilterContextListener.java @@ -43,5 +43,5 @@ public interface StatFilterContextListener { void clob_open(); - void clob_free(); + void blob_open(); } diff --git a/src/main/java/com/alibaba/druid/filter/stat/StatFilterContextListenerAdapter.java b/src/main/java/com/alibaba/druid/filter/stat/StatFilterContextListenerAdapter.java index 47dcea1061..839fddaab9 100644 --- a/src/main/java/com/alibaba/druid/filter/stat/StatFilterContextListenerAdapter.java +++ b/src/main/java/com/alibaba/druid/filter/stat/StatFilterContextListenerAdapter.java @@ -81,11 +81,12 @@ public class StatFilterContextListenerAdapter implements StatFilterContextListen public void clob_open() { } - + @Override - public void clob_free() { + public void blob_open() { } + } diff --git a/src/main/java/com/alibaba/druid/mock/MockStatement.java b/src/main/java/com/alibaba/druid/mock/MockStatement.java index 6bbf5394d1..18001a5431 100644 --- a/src/main/java/com/alibaba/druid/mock/MockStatement.java +++ b/src/main/java/com/alibaba/druid/mock/MockStatement.java @@ -36,7 +36,7 @@ public class MockStatement extends StatementBase implements MockStatementBase, S } } - protected void checkOpen() throws SQLException, MockConnectionClosedException { + protected void checkOpen() throws SQLException { if (closed) { throw new SQLException(); } diff --git a/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java b/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java index 27003bacdb..87680676a1 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java +++ b/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java @@ -1378,22 +1378,15 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements map.put("StatementExecuteCount", stat.getStatementStat().getExecuteCount()); map.put("StatementRunningCount", stat.getStatementStat().getRunningCount()); - // 15 -24 + // 15 - 19 map.put("StatementConcurrentMax", stat.getStatementStat().getConcurrentMax()); map.put("StatementCloseCount", stat.getStatementStat().getCloseCount()); map.put("StatementErrorCount", stat.getStatementStat().getErrorCount()); - Throwable lastStatementError = stat.getStatementStat().getLastException(); - if (lastStatementError != null) { - map.put("StatementLastErrorTime", stat.getStatementStat().getLastErrorTime()); - map.put("StatementLastErrorMessage", lastStatementError.getMessage()); + map.put("StatementLastErrorTime", null); + map.put("StatementLastErrorMessage", null); - map.put("StatementLastErrorStackTrace", IOUtils.getStackTrace(lastStatementError)); - } else { - map.put("StatementLastErrorTime", null); - map.put("StatementLastErrorMessage", null); - - map.put("StatementLastErrorStackTrace", null); - } + // 20 - 24 + map.put("StatementLastErrorStackTrace", null); map.put("StatementExecuteMillisTotal", stat.getStatementStat().getMillisTotal()); map.put("StatementExecuteLastTime", stat.getStatementStat().getExecuteLastTime()); map.put("ConnectionConnectingCount", stat.getConnectionStat().getConnectingCount()); @@ -1410,21 +1403,14 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements map.put("ResultSetErrorCount", stat.getResultSetStat().getErrorCount()); map.put("ResultSetOpenningMillisTotal", stat.getResultSetStat().getAliveMillisTotal()); map.put("ResultSetLastErrorTime", stat.getResultSetStat().getLastErrorTime()); - Throwable lastResultSetError = stat.getResultSetStat().getLastError(); - if (lastResultSetError != null) { - map.put("ResultSetLastErrorMessage", lastResultSetError.getMessage()); - map.put("ResultSetLastErrorStackTrace", IOUtils.getStackTrace(lastResultSetError)); - } else { - map.put("ResultSetLastErrorMessage", null); - map.put("ResultSetLastErrorStackTrace", null); - } + map.put("ResultSetLastErrorMessage", null); + map.put("ResultSetLastErrorStackTrace", null); // 35 - 39 - map.put("ConnectionConnectCount", stat.getConnectionStat().getConnectCount()); - Throwable lastConnectionError = stat.getConnectionStat().getErrorLast(); - if (lastConnectionError != null) { - map.put("ConnectionErrorLastMessage", lastConnectionError.getMessage()); - map.put("ConnectionErrorLastStackTrace", IOUtils.getStackTrace(lastConnectionError)); + map.put("ConnectionConnectCount", createErrorCount); + if (createError != null) { + map.put("ConnectionErrorLastMessage", createError.getMessage()); + map.put("ConnectionErrorLastStackTrace", IOUtils.getStackTrace(createError)); } else { map.put("ConnectionErrorLastMessage", null); map.put("ConnectionErrorLastStackTrace", null); diff --git a/src/main/java/com/alibaba/druid/pool/DruidConnectionHolder.java b/src/main/java/com/alibaba/druid/pool/DruidConnectionHolder.java index f8dba8ef5b..46088b0fd2 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidConnectionHolder.java +++ b/src/main/java/com/alibaba/druid/pool/DruidConnectionHolder.java @@ -70,8 +70,9 @@ public final class DruidConnectionHolder { try { this.underlyingTransactionIsolation = conn.getTransactionIsolation(); } catch (SQLException e) { - if ("com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException".equals(e.getClass().getName())) - ; + if (!"com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException".equals(e.getClass().getName())) { + throw e; + } } this.defaultHoldability = underlyingHoldability; @@ -214,10 +215,9 @@ public final class DruidConnectionHolder { buf.append("\""); } - PreparedStatementPool statmentPool = this.getStatementPool(); - if (statmentPool != null && statmentPool.getMap().size() > 0) { + if (statementPool != null && statementPool.getMap().size() > 0) { buf.append("\", CachedStatementCount:"); - buf.append(this.getStatementPool().getMap().size()); + buf.append(statementPool.getMap().size()); } buf.append("}"); diff --git a/src/main/java/com/alibaba/druid/pool/DruidDataSource.java b/src/main/java/com/alibaba/druid/pool/DruidDataSource.java index ab3eccbbbb..1e920a115a 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidDataSource.java +++ b/src/main/java/com/alibaba/druid/pool/DruidDataSource.java @@ -403,7 +403,8 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat // 初始化连接 for (int i = 0, size = getInitialSize(); i < size; ++i) { Connection conn = createPhysicalConnection(); - connections[poolingCount++] = new DruidConnectionHolder(this, conn); + DruidConnectionHolder holder = new DruidConnectionHolder(this, conn); + connections[poolingCount++] = holder; } if (poolingCount > 0) { @@ -536,7 +537,9 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat } } else if (JdbcUtils.MYSQL.equals(this.dbType)) { if (!this.isTestWhileIdle()) { - if (LOG.isWarnEnabled()) LOG.warn("Your dbType is mysql, recommend set testWhileIdle is true"); + if (LOG.isWarnEnabled()) { + LOG.warn("Your dbType is mysql, recommend set testWhileIdle is true"); + } } } } @@ -815,7 +818,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat discardConnection(holder.getConnection()); return; } - + final long lastActiveTimeMillis = System.currentTimeMillis(); lock.lockInterruptibly(); try { @@ -1173,9 +1176,17 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat continue; } + DruidConnectionHolder holder = null; + try { + holder = new DruidConnectionHolder(DruidDataSource.this, connection); + } catch (SQLException ex) { + LOG.error("create connection holder error", ex); + break; + } + lock.lock(); try { - connections[poolingCount++] = new DruidConnectionHolder(DruidDataSource.this, connection); + connections[poolingCount++] = holder; if (poolingCount > poolingPeak) { poolingPeak = poolingCount; @@ -1186,9 +1197,6 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat notEmpty.signal(); notEmptySignalCount++; - } catch (SQLException ex) { - LOG.error("create connection holder error", ex); - break; } finally { lock.unlock(); } @@ -1209,6 +1217,10 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat for (;;) { // 从前面开始删除 try { + if (closed) { + break; + } + if (timeBetweenEvictionRunsMillis > 0) { Thread.sleep(timeBetweenEvictionRunsMillis); } else { @@ -1521,31 +1533,29 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat buf.append(System.identityHashCode(conn.getConnection())); PreparedStatementPool pool = conn.getStatementPool(); - if (pool != null) { - buf.append(", \n\tpoolStatements:["); + buf.append(", \n\tpoolStatements:["); - int entryIndex = 0; - try { - for (Map.Entry entry : pool.getMap().entrySet()) { - if (entryIndex != 0) { - buf.append(","); - } - buf.append("\n\t\t{hitCount:"); - buf.append(entry.getValue().getHitCount()); - buf.append(",sql:\""); - buf.append(entry.getKey().getSql()); - buf.append("\""); - buf.append("\t}"); - - entryIndex++; + int entryIndex = 0; + try { + for (Map.Entry entry : pool.getMap().entrySet()) { + if (entryIndex != 0) { + buf.append(","); } - } catch (ConcurrentModificationException e) { - // skip .. - } + buf.append("\n\t\t{hitCount:"); + buf.append(entry.getValue().getHitCount()); + buf.append(",sql:\""); + buf.append(entry.getKey().getSql()); + buf.append("\""); + buf.append("\t}"); - buf.append("\n\t\t]"); + entryIndex++; + } + } catch (ConcurrentModificationException e) { + // skip .. } + buf.append("\n\t\t]"); + buf.append("\n\t}"); } } @@ -1774,6 +1784,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat dataMap.put("ConnectionHoldTimeHistogram", this.getDataSourceStat().getConnectionHoldHistogram().toArray()); dataMap.put("RemoveAbandoned", this.isRemoveAbandoned()); dataMap.put("ClobOpenCount", this.getDataSourceStat().getClobOpenCount()); + dataMap.put("BlobOpenCount", this.getDataSourceStat().getBlobOpenCount()); return dataMap; } diff --git a/src/main/java/com/alibaba/druid/pool/DruidDataSourceC3P0Adapter.java b/src/main/java/com/alibaba/druid/pool/DruidDataSourceC3P0Adapter.java index 4f6b25ab20..18b79451dd 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidDataSourceC3P0Adapter.java +++ b/src/main/java/com/alibaba/druid/pool/DruidDataSourceC3P0Adapter.java @@ -36,21 +36,15 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3 dataSource = new DruidDataSource(); // setDefault - this.setInitialPoolSize(3); - this.setAcquireIncrement(3); - this.setAcquireIncrement(30); - this.setAcquireRetryDelay(1000); - this.setAutoCommitOnClose(true); - this.setAutomaticTestTable(null); - this.setCheckoutTimeout(0); - this.setDebugUnreturnedConnectionStackTraces(false); - this.setMaxIdleTime(0); - this.setMaxPoolSize(15); - this.setMaxStatements(0); - this.setMaxStatementsPerConnection(0); - this.setMinPoolSize(3); - this.setTestConnectionOnCheckin(false); - this.setTestConnectionOnCheckout(false); + dataSource.setInitialSize(3); + acquireIncrement = 3; + dataSource.setTimeBetweenConnectErrorMillis(1000); + dataSource.setDefaultAutoCommit(true); + dataSource.setLogAbandoned(false); + dataSource.setMaxActive(15); + dataSource.setMinIdle(3); + dataSource.setTestOnReturn(false); + dataSource.setTestOnBorrow(false); } @Override @@ -279,8 +273,6 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3 } public void setMaxStatementsPerConnection(int maxStatementsPerConnection) { - dataSource.setPoolPreparedStatements(maxStatementsPerConnection > 0); - dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxStatementsPerConnection); } @@ -289,8 +281,6 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3 } public void setMaxStatements(int maxStatements) { - dataSource.setPoolPreparedStatements(maxStatements > 0); - dataSource.setMaxOpenPreparedStatements(maxStatements); } @@ -493,6 +483,6 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3 } public Logger getParentLogger() throws SQLFeatureNotSupportedException { - throw new SQLFeatureNotSupportedException(); + return dataSource.getParentLogger(); } } diff --git a/src/main/java/com/alibaba/druid/pool/DruidPooledPreparedStatement.java b/src/main/java/com/alibaba/druid/pool/DruidPooledPreparedStatement.java index f9139cad2e..4f462272f1 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidPooledPreparedStatement.java +++ b/src/main/java/com/alibaba/druid/pool/DruidPooledPreparedStatement.java @@ -180,6 +180,10 @@ public class DruidPooledPreparedStatement extends DruidPooledStatement implement conn.beforeExecute(); try { ResultSet rs = stmt.executeQuery(); + + if (rs == null) { + return null; + } DruidPooledResultSet poolableResultSet = new DruidPooledResultSet(this, rs); resultSetTrace.add(poolableResultSet); diff --git a/src/main/java/com/alibaba/druid/pool/DruidPooledStatement.java b/src/main/java/com/alibaba/druid/pool/DruidPooledStatement.java index e402d1472f..b5fa0f6e7f 100644 --- a/src/main/java/com/alibaba/druid/pool/DruidPooledStatement.java +++ b/src/main/java/com/alibaba/druid/pool/DruidPooledStatement.java @@ -107,6 +107,10 @@ public class DruidPooledStatement extends PoolableWrapper implements Statement { conn.beforeExecute(); try { ResultSet rs = stmt.executeQuery(sql); + + if (rs == null) { + return rs; + } DruidPooledResultSet poolableResultSet = new DruidPooledResultSet(this, rs); resultSetTrace.add(poolableResultSet); diff --git a/src/main/java/com/alibaba/druid/pool/ha/MultiDataSource.java b/src/main/java/com/alibaba/druid/pool/ha/MultiDataSource.java index ed4b43c168..2cf4235f7a 100644 --- a/src/main/java/com/alibaba/druid/pool/ha/MultiDataSource.java +++ b/src/main/java/com/alibaba/druid/pool/ha/MultiDataSource.java @@ -255,7 +255,9 @@ public class MultiDataSource extends DataSourceAdapter implements MultiDataSourc } public void close() { - scheduler.shutdownNow(); + if (scheduler != null) { + scheduler.shutdownNow(); + } Object[] items = this.getDataSources().values().toArray(); for (Object item : items) { diff --git a/src/main/java/com/alibaba/druid/pool/ha/MultiDataSourceConnection.java b/src/main/java/com/alibaba/druid/pool/ha/MultiDataSourceConnection.java index 5d1f197049..846d7d5d96 100644 --- a/src/main/java/com/alibaba/druid/pool/ha/MultiDataSourceConnection.java +++ b/src/main/java/com/alibaba/druid/pool/ha/MultiDataSourceConnection.java @@ -633,7 +633,7 @@ public class MultiDataSourceConnection extends WrapperAdapter implements Connect public boolean isWrapperFor(Class iface) throws SQLException { boolean result = super.isWrapperFor(iface); - if (result == false && conn != null) { + if ((!result) && conn != null) { result = conn.isWrapperFor(iface); } diff --git a/src/main/java/com/alibaba/druid/pool/ha/cobar/CobarDataSource.java b/src/main/java/com/alibaba/druid/pool/ha/cobar/CobarDataSource.java index 085c537e49..cb83ae2738 100644 --- a/src/main/java/com/alibaba/druid/pool/ha/cobar/CobarDataSource.java +++ b/src/main/java/com/alibaba/druid/pool/ha/cobar/CobarDataSource.java @@ -31,10 +31,10 @@ public class CobarDataSource extends MultiDataSource { private final static Log LOG = LogFactory.getLog(CobarDataSource.class); - public static long DEFAULT_FAILURE_DETECT_PERRIOD_MILLIS = 1000 * 3; // 3 - // seconds - public static long DEFAULT_CONFIG_LOAD_PERRIOD_MILLIS = 1000 * 60 * 3; // 3 - // minutes + public final static long DEFAULT_FAILURE_DETECT_PERRIOD_MILLIS = 1000 * 3; // 3 + // seconds + public final static long DEFAULT_CONFIG_LOAD_PERRIOD_MILLIS = 1000 * 60 * 3; // 3 + // minutes private String url; @@ -50,7 +50,6 @@ public class CobarDataSource extends MultiDataSource { private List proxyFilters = new ArrayList(); private String filters; - public CobarDataSource(){ this.setFailureDetector(new CobarFailureDetecter()); this.setFailureDetectPeriodMillis(DEFAULT_FAILURE_DETECT_PERRIOD_MILLIS); @@ -122,7 +121,7 @@ public class CobarDataSource extends MultiDataSource { if (this.getConfigLoader() == null) { this.setConfigLoader(new CobarConfigLoader(this)); } - + final int RETRY_COUNT = 3; for (int i = 0; i < RETRY_COUNT; ++i) { try { diff --git a/src/main/java/com/alibaba/druid/pool/ha/cobar/CobarFailureDetecter.java b/src/main/java/com/alibaba/druid/pool/ha/cobar/CobarFailureDetecter.java index 52a68a69fd..fd620dbc20 100644 --- a/src/main/java/com/alibaba/druid/pool/ha/cobar/CobarFailureDetecter.java +++ b/src/main/java/com/alibaba/druid/pool/ha/cobar/CobarFailureDetecter.java @@ -56,11 +56,7 @@ public class CobarFailureDetecter extends DefaultDataSourceFailureDetecter { String status = rs.getString(1); - if ("on".equalsIgnoreCase(status)) { - return true; - } else { - return false; - } + return "on".equalsIgnoreCase(status); } catch (Exception ex) { LOG.error("check datasource valid errror", ex); return false; diff --git a/src/main/java/com/alibaba/druid/proxy/DruidDriver.java b/src/main/java/com/alibaba/druid/proxy/DruidDriver.java index 14e0fca618..2fe34a13cc 100644 --- a/src/main/java/com/alibaba/druid/proxy/DruidDriver.java +++ b/src/main/java/com/alibaba/druid/proxy/DruidDriver.java @@ -250,9 +250,9 @@ public class DruidDriver implements Driver, DruidDriverMBean { try { rawDriver = (Driver) rawDriverClass.newInstance(); } catch (InstantiationException e) { - throw new SQLException("create driver instance error, driver className '" + className + "'"); + throw new SQLException("create driver instance error, driver className '" + className + "'", e); } catch (IllegalAccessException e) { - throw new SQLException("create driver instance error, driver className '" + className + "'"); + throw new SQLException("create driver instance error, driver className '" + className + "'", e); } return rawDriver; diff --git a/src/main/java/com/alibaba/druid/proxy/config/AbstractDruidFilterConfig.java b/src/main/java/com/alibaba/druid/proxy/config/AbstractDruidFilterConfig.java deleted file mode 100644 index 8f880b0162..0000000000 --- a/src/main/java/com/alibaba/druid/proxy/config/AbstractDruidFilterConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 1999-2011 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.alibaba.druid.proxy.config; - -/** - * @author gang.su - */ -public abstract class AbstractDruidFilterConfig { - - private String name; - private String clazz; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getClazz() { - return clazz; - } - - public void setClazz(String clazz) { - this.clazz = clazz; - } - -} diff --git a/src/main/java/com/alibaba/druid/proxy/config/DruidFilterConfig.java b/src/main/java/com/alibaba/druid/proxy/config/DruidFilterConfig.java deleted file mode 100644 index e747d3bbe5..0000000000 --- a/src/main/java/com/alibaba/druid/proxy/config/DruidFilterConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 1999-2011 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.alibaba.druid.proxy.config; - -/** - * @author gang.su - */ -public class DruidFilterConfig extends AbstractDruidFilterConfig { - -} diff --git a/src/main/java/com/alibaba/druid/proxy/config/EncodingDruidFilterConfig.java b/src/main/java/com/alibaba/druid/proxy/config/EncodingDruidFilterConfig.java deleted file mode 100644 index 878fbb88b1..0000000000 --- a/src/main/java/com/alibaba/druid/proxy/config/EncodingDruidFilterConfig.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 1999-2011 Alibaba Group Holding Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.alibaba.druid.proxy.config; - -/** - * druid filter配置 来源于配置文件 - * - * @author gang.su - */ -public class EncodingDruidFilterConfig extends AbstractDruidFilterConfig { - - private String clientEncoding; - - private String serverEncoding; - - public String getClientEncoding() { - return clientEncoding; - } - - public void setClientEncoding(String clientEncoding) { - this.clientEncoding = clientEncoding; - } - - public String getServerEncoding() { - return serverEncoding; - } - - public void setServerEncoding(String serverEncoding) { - this.serverEncoding = serverEncoding; - } - -} diff --git a/src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxy.java b/src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxy.java index f6a6ff7ef2..4b4e327d8d 100644 --- a/src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxy.java +++ b/src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxy.java @@ -43,4 +43,20 @@ public interface ResultSetProxy extends ResultSet, WrapperProxy { void setConstructNano(); int getCloseCount(); + + void addReadStringLength(int length); + + long getReadStringLength(); + + void addReadBytesLength(int length); + + long getReadBytesLength(); + + void incrementOpenInputStreamCount(); + + int getOpenInputStreamCount(); + + void incrementOpenReaderCount(); + + int getOpenReaderCount(); } diff --git a/src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxyImpl.java b/src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxyImpl.java index 45017f8596..ab54e36ada 100644 --- a/src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxyImpl.java +++ b/src/main/java/com/alibaba/druid/proxy/jdbc/ResultSetProxyImpl.java @@ -51,11 +51,17 @@ public class ResultSetProxyImpl extends WrapperProxyImpl implements ResultSetPro private final StatementProxy statement; private final String sql; - protected int cursorIndex = 0; - protected int fetchRowCount = 0; + protected int cursorIndex = 0; + protected int fetchRowCount = 0; protected long constructNano; protected final JdbcSqlStat sqlStat; - private int closeCount = 0; + private int closeCount = 0; + + private long readStringLength = 0; + private long readBytesLength = 0; + + private int openInputStreamCount = 0; + private int openReaderCount = 0; public ResultSetProxyImpl(StatementProxy statement, ResultSet resultSet, long id, String sql){ super(resultSet, id); @@ -1078,4 +1084,44 @@ public class ResultSetProxyImpl extends WrapperProxyImpl implements ResultSetPro return closeCount; } + @Override + public void addReadStringLength(int length) { + this.readStringLength += length; + } + + @Override + public long getReadStringLength() { + return readStringLength; + } + + @Override + public void addReadBytesLength(int length) { + this.readBytesLength += length; + } + + @Override + public long getReadBytesLength() { + return readBytesLength; + } + + @Override + public void incrementOpenInputStreamCount() { + openInputStreamCount++; + } + + @Override + public int getOpenInputStreamCount() { + return openInputStreamCount; + } + + @Override + public void incrementOpenReaderCount() { + openReaderCount++; + } + + @Override + public int getOpenReaderCount() { + return openReaderCount; + } + } diff --git a/src/main/java/com/alibaba/druid/sql/ast/SQLObjectImpl.java b/src/main/java/com/alibaba/druid/sql/ast/SQLObjectImpl.java index 9ead39483c..258dee05cd 100644 --- a/src/main/java/com/alibaba/druid/sql/ast/SQLObjectImpl.java +++ b/src/main/java/com/alibaba/druid/sql/ast/SQLObjectImpl.java @@ -48,8 +48,9 @@ public abstract class SQLObjectImpl implements SQLObject, Serializable { protected abstract void accept0(SQLASTVisitor visitor); protected final void acceptChild(SQLASTVisitor visitor, List children) { - for (SQLObject child : children) + for (SQLObject child : children) { acceptChild(visitor, child); + } } protected final void acceptChild(SQLASTVisitor visitor, SQLObject child) { diff --git a/src/main/java/com/alibaba/druid/sql/ast/expr/SQLBetweenExpr.java b/src/main/java/com/alibaba/druid/sql/ast/expr/SQLBetweenExpr.java index f32704d7d0..5ddc9b7a35 100644 --- a/src/main/java/com/alibaba/druid/sql/ast/expr/SQLBetweenExpr.java +++ b/src/main/java/com/alibaba/druid/sql/ast/expr/SQLBetweenExpr.java @@ -50,8 +50,9 @@ public class SQLBetweenExpr extends SQLExprImpl implements Serializable { public void output(StringBuffer buf) { this.testExpr.output(buf); - if (this.not) buf.append(" NOT BETWEEN "); - else { + if (this.not) { + buf.append(" NOT BETWEEN "); + } else { buf.append(" BETWEEN "); } this.beginExpr.output(buf); diff --git a/src/main/java/com/alibaba/druid/sql/ast/expr/SQLInListExpr.java b/src/main/java/com/alibaba/druid/sql/ast/expr/SQLInListExpr.java index 9ce6c13eef..cfc79d5ef6 100644 --- a/src/main/java/com/alibaba/druid/sql/ast/expr/SQLInListExpr.java +++ b/src/main/java/com/alibaba/druid/sql/ast/expr/SQLInListExpr.java @@ -72,8 +72,9 @@ public class SQLInListExpr extends SQLExprImpl implements Serializable { public void output(StringBuffer buf) { this.expr.output(buf); - if (this.not) buf.append("NOT IN "); - else { + if (this.not) { + buf.append("NOT IN "); + } else { buf.append("IN "); } diff --git a/src/main/java/com/alibaba/druid/sql/ast/statement/SQLSelect.java b/src/main/java/com/alibaba/druid/sql/ast/statement/SQLSelect.java index cfae764fc0..ec26633f9d 100644 --- a/src/main/java/com/alibaba/druid/sql/ast/statement/SQLSelect.java +++ b/src/main/java/com/alibaba/druid/sql/ast/statement/SQLSelect.java @@ -50,7 +50,9 @@ public class SQLSelect extends SQLObjectImpl { this.query.output(buf); buf.append(" "); - if (this.orderBy != null) this.orderBy.output(buf); + if (this.orderBy != null) { + this.orderBy.output(buf); + } } protected void accept0(SQLASTVisitor visitor) { diff --git a/src/main/java/com/alibaba/druid/sql/ast/statement/SQLSelectQueryBlock.java b/src/main/java/com/alibaba/druid/sql/ast/statement/SQLSelectQueryBlock.java index feec54aa4a..b2cb7b96bf 100644 --- a/src/main/java/com/alibaba/druid/sql/ast/statement/SQLSelectQueryBlock.java +++ b/src/main/java/com/alibaba/druid/sql/ast/statement/SQLSelectQueryBlock.java @@ -100,9 +100,11 @@ public class SQLSelectQueryBlock extends SQLSelectQuery { public void output(StringBuffer buf) { buf.append("SELECT "); - if (SQLSetQuantifier.ALL == this.distionOption) buf.append("ALL "); - else if (SQLSetQuantifier.DISTINCT == this.distionOption) buf.append("DISTINCT "); - else if (SQLSetQuantifier.UNIQUE == this.distionOption) { + if (SQLSetQuantifier.ALL == this.distionOption) { + buf.append("ALL "); + } else if (SQLSetQuantifier.DISTINCT == this.distionOption) { + buf.append("DISTINCT "); + } else if (SQLSetQuantifier.UNIQUE == this.distionOption) { buf.append("UNIQUE "); } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/hive/parser/HiveExprParser.java b/src/main/java/com/alibaba/druid/sql/dialect/hive/parser/HiveExprParser.java index fbaee61ff2..1c1fc3e891 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/hive/parser/HiveExprParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/hive/parser/HiveExprParser.java @@ -16,12 +16,11 @@ package com.alibaba.druid.sql.dialect.hive.parser; import com.alibaba.druid.sql.parser.Lexer; -import com.alibaba.druid.sql.parser.ParserException; import com.alibaba.druid.sql.parser.SQLExprParser; public class HiveExprParser extends SQLExprParser { - public HiveExprParser(String sql) throws ParserException{ + public HiveExprParser(String sql) { super(new HiveLexer(sql)); this.lexer.nextToken(); } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlCreateTableParser.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlCreateTableParser.java index 1a6c8c8ef5..0c70d275c3 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlCreateTableParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlCreateTableParser.java @@ -32,7 +32,7 @@ import com.alibaba.druid.sql.parser.Token; public class MySqlCreateTableParser extends SQLCreateTableParser { - public MySqlCreateTableParser(String sql) throws ParserException{ + public MySqlCreateTableParser(String sql) { super(new MySqlExprParser(sql)); } @@ -40,11 +40,11 @@ public class MySqlCreateTableParser extends SQLCreateTableParser { super(exprParser); } - public SQLCreateTableStatement parseCrateTable() throws ParserException { + public SQLCreateTableStatement parseCrateTable() { return parseCrateTable(true); } - public MySqlCreateTableStatement parseCrateTable(boolean acceptCreate) throws ParserException { + public MySqlCreateTableStatement parseCrateTable(boolean acceptCreate) { if (acceptCreate) { accept(Token.CREATE); } @@ -182,7 +182,7 @@ public class MySqlCreateTableParser extends SQLCreateTableParser { } @SuppressWarnings("unused") - protected SQLTableConstaint parseConstraint() throws ParserException { + protected SQLTableConstaint parseConstraint() { SQLName name = null; if (lexer.token() == (Token.CONSTRAINT)) { lexer.nextToken(); diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlExprParser.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlExprParser.java index 7d9a2e90a8..4eecb8a673 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlExprParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlExprParser.java @@ -52,12 +52,12 @@ public class MySqlExprParser extends SQLExprParser { super(lexer); } - public MySqlExprParser(String sql) throws ParserException{ + public MySqlExprParser(String sql) { this(new MySqlLexer(sql)); this.lexer.nextToken(); } - public SQLExpr relationalRest(SQLExpr expr) throws ParserException { + public SQLExpr relationalRest(SQLExpr expr) { if (identifierEquals("REGEXP")) { lexer.nextToken(); SQLExpr rightExp = equality(); @@ -79,7 +79,7 @@ public class MySqlExprParser extends SQLExprParser { return super.relationalRest(expr); } - public SQLExpr multiplicativeRest(SQLExpr expr) throws ParserException { + public SQLExpr multiplicativeRest(SQLExpr expr) { if (lexer.token() == Token.IDENTIFIER && "MOD".equalsIgnoreCase(lexer.stringVal())) { lexer.nextToken(); SQLExpr rightExp = primary(); @@ -114,7 +114,7 @@ public class MySqlExprParser extends SQLExprParser { return super.notRationalRest(expr); } - public SQLExpr primary() throws ParserException { + public SQLExpr primary() { final Token tok = lexer.token(); if (identifierEquals("outfile")) { @@ -158,7 +158,7 @@ public class MySqlExprParser extends SQLExprParser { } - public final SQLExpr primaryRest(SQLExpr expr) throws ParserException { + public final SQLExpr primaryRest(SQLExpr expr) { if (expr == null) { throw new IllegalArgumentException("expr"); } @@ -317,8 +317,8 @@ public class MySqlExprParser extends SQLExprParser { if (lexer.token() == Token.FOR) { lexer.nextToken(); - SQLExpr _for = expr(); - methodInvokeExpr.putAttribute("FOR", _for); + SQLExpr forExpr = expr(); + methodInvokeExpr.putAttribute("FOR", forExpr); } break; } else if (lexer.token() == Token.RPAREN) { @@ -489,7 +489,7 @@ public class MySqlExprParser extends SQLExprParser { } } - public SQLColumnDefinition parseColumn() throws ParserException { + public SQLColumnDefinition parseColumn() { MySqlSQLColumnDefinition column = new MySqlSQLColumnDefinition(); column.setName(name()); column.setDataType(parseDataType()); @@ -497,7 +497,7 @@ public class MySqlExprParser extends SQLExprParser { return parseColumnRest(column); } - public SQLColumnDefinition parseColumnRest(SQLColumnDefinition column) throws ParserException { + public SQLColumnDefinition parseColumnRest(SQLColumnDefinition column) { if (identifierEquals("AUTO_INCREMENT")) { lexer.nextToken(); if (column instanceof MySqlSQLColumnDefinition) { @@ -514,7 +514,7 @@ public class MySqlExprParser extends SQLExprParser { return column; } - public SQLExpr orRest(SQLExpr expr) throws ParserException { + public SQLExpr orRest(SQLExpr expr) { for (;;) { if (lexer.token() == Token.OR || lexer.token() == Token.BARBAR) { @@ -566,7 +566,7 @@ public class MySqlExprParser extends SQLExprParser { return item; } - public SQLName nameRest(SQLName name) throws ParserException { + public SQLName nameRest(SQLName name) { if (lexer.token() == Token.VARIANT && "@".equals(lexer.stringVal())) { lexer.nextToken(); MySqlUserName userName = new MySqlUserName(); diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlSelectParser.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlSelectParser.java index db6c4d93ab..bb39281bd1 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlSelectParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlSelectParser.java @@ -44,12 +44,12 @@ public class MySqlSelectParser extends SQLSelectParser { super(exprParser); } - public MySqlSelectParser(String sql) throws ParserException{ + public MySqlSelectParser(String sql) { this(new MySqlExprParser(sql)); } @Override - public SQLSelectQuery query() throws ParserException { + public SQLSelectQuery query() { if (lexer.token() == (Token.LPAREN)) { lexer.nextToken(); @@ -220,7 +220,7 @@ public class MySqlSelectParser extends SQLSelectParser { return queryRest(queryBlock); } - protected void parseGroupBy(SQLSelectQueryBlock queryBlock) throws ParserException { + protected void parseGroupBy(SQLSelectQueryBlock queryBlock) { if (lexer.token() == (Token.GROUP)) { lexer.nextToken(); accept(Token.BY); @@ -228,7 +228,9 @@ public class MySqlSelectParser extends SQLSelectParser { SQLSelectGroupByClause groupBy = new SQLSelectGroupByClause(); while (true) { groupBy.getItems().add(this.exprParser.expr()); - if (!(lexer.token() == (Token.COMMA))) break; + if (!(lexer.token() == (Token.COMMA))) { + break; + } lexer.nextToken(); } @@ -253,7 +255,7 @@ public class MySqlSelectParser extends SQLSelectParser { } } - protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) throws ParserException { + protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) { if (identifierEquals("USING")) { return tableSource; } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java index 0dfa5e0e51..03fddc5806 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/parser/MySqlStatementParser.java @@ -129,35 +129,65 @@ import com.alibaba.druid.sql.parser.Token; public class MySqlStatementParser extends SQLStatementParser { - public MySqlStatementParser(String sql) throws ParserException{ - super (new MySqlExprParser(sql)); + private static final String COLLATE2 = "COLLATE"; + private static final String CASCADE = "CASCADE"; + private static final String RESTRICT = "RESTRICT"; + private static final String CHAIN = "CHAIN"; + private static final String ENGINES = "ENGINES"; + private static final String ENGINE = "ENGINE"; + private static final String BINLOG = "BINLOG"; + private static final String EVENTS = "EVENTS"; + private static final String CHARACTER = "CHARACTER"; + private static final String SESSION = "SESSION"; + private static final String GLOBAL = "GLOBAL"; + private static final String VARIABLES = "VARIABLES"; + private static final String ERRORS = "ERRORS"; + private static final String STATUS = "STATUS"; + private static final String IGNORE = "IGNORE"; + private static final String RESET = "RESET"; + private static final String DESCRIBE = "DESCRIBE"; + private static final String DESC = "DESC"; + private static final String WRITE = "WRITE"; + private static final String READ = "READ"; + private static final String LOCAL = "LOCAL"; + private static final String TABLES = "TABLES"; + private static final String TEMPORARY = "TEMPORARY"; + private static final String USER = "USER"; + private static final String SPATIAL = "SPATIAL"; + private static final String FULLTEXT = "FULLTEXT"; + private static final String REPLACE = "REPLACE"; + private static final String DELAYED = "DELAYED"; + private static final String LOW_PRIORITY = "LOW_PRIORITY"; + + public MySqlStatementParser(String sql){ + super(new MySqlExprParser(sql)); } public MySqlStatementParser(Lexer lexer){ super(new MySqlExprParser(lexer)); } - public SQLCreateTableStatement parseCreateTable() throws ParserException { + public SQLCreateTableStatement parseCreateTable() { MySqlCreateTableParser parser = new MySqlCreateTableParser(this.exprParser); return parser.parseCrateTable(); } - public SQLSelectStatement parseSelect() throws ParserException { + public SQLSelectStatement parseSelect() { return new SQLSelectStatement(new MySqlSelectParser(this.exprParser).select()); } - public SQLUpdateStatement parseUpdateStatement() throws ParserException { + public SQLUpdateStatement parseUpdateStatement() { MySqlUpdateStatement stmt = createUpdateStatement(); if (lexer.token() == Token.UPDATE) { lexer.nextToken(); - - if (identifierEquals("LOW_PRIORITY")) { + + if (identifierEquals(LOW_PRIORITY)) { lexer.nextToken(); stmt.setLowPriority(true); } - - if (identifierEquals("IGNORE")) { + + if (identifierEquals(IGNORE)) { lexer.nextToken(); stmt.setIgnore(true); } @@ -192,7 +222,7 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); stmt.setWhere(this.exprParser.expr()); } - + stmt.setOrderBy(this.exprParser.parseOrderBy()); stmt.setLimit(parseLimit()); @@ -204,13 +234,13 @@ public class MySqlStatementParser extends SQLStatementParser { return new MySqlUpdateStatement(); } - public MySqlDeleteStatement parseDeleteStatement() throws ParserException { + public MySqlDeleteStatement parseDeleteStatement() { MySqlDeleteStatement deleteStatement = new MySqlDeleteStatement(); if (lexer.token() == Token.DELETE) { lexer.nextToken(); - if (identifierEquals("LOW_PRIORITY")) { + if (identifierEquals(LOW_PRIORITY)) { deleteStatement.setLowPriority(true); lexer.nextToken(); } @@ -220,7 +250,7 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); } - if (identifierEquals("IGNORE")) { + if (identifierEquals(IGNORE)) { deleteStatement.setIgnore(true); lexer.nextToken(); } @@ -264,45 +294,45 @@ public class MySqlStatementParser extends SQLStatementParser { return deleteStatement; } - public SQLStatement parseCreate() throws ParserException { + public SQLStatement parseCreate() { accept(Token.CREATE); List hints = this.exprParser.parseHints(); - - if (lexer.token() == Token.TABLE || identifierEquals("TEMPORARY")) { + + if (lexer.token() == Token.TABLE || identifierEquals(TEMPORARY)) { MySqlCreateTableParser parser = new MySqlCreateTableParser(this.exprParser); MySqlCreateTableStatement stmt = parser.parseCrateTable(false); stmt.setHints(hints); return stmt; } - + if (lexer.token() == Token.DATABASE) { return parseCreateDatabase(); } - if (lexer.token() == Token.UNIQUE || lexer.token() == Token.INDEX || identifierEquals("FULLTEXT") - || identifierEquals("SPATIAL")) { + if (lexer.token() == Token.UNIQUE || lexer.token() == Token.INDEX || identifierEquals(FULLTEXT) + || identifierEquals(SPATIAL)) { return parseCreateIndex(); } - if (identifierEquals("USER")) { + if (identifierEquals(USER)) { return parseCreateUser(); } throw new ParserException("TODO " + lexer.token()); } - public SQLStatement parseCreateIndex() throws ParserException { + public SQLStatement parseCreateIndex() { MySqlCreateIndexStatement stmt = new MySqlCreateIndexStatement(); if (lexer.token() == Token.UNIQUE) { stmt.setType("UNIQUE"); lexer.nextToken(); - } else if (identifierEquals("FULLTEXT")) { - stmt.setType("FULLTEXT"); + } else if (identifierEquals(FULLTEXT)) { + stmt.setType(FULLTEXT); lexer.nextToken(); - } else if (identifierEquals("SPATIAL")) { - stmt.setType("SPATIAL"); + } else if (identifierEquals(SPATIAL)) { + stmt.setType(SPATIAL); lexer.nextToken(); } @@ -350,12 +380,12 @@ public class MySqlStatementParser extends SQLStatementParser { } } - public SQLStatement parseCreateUser() throws ParserException { + public SQLStatement parseCreateUser() { if (lexer.token() == Token.CREATE) { lexer.nextToken(); } - acceptIdentifier("USER"); + acceptIdentifier(USER); MySqlCreateUserStatement stmt = new MySqlCreateUserStatement(); @@ -430,7 +460,7 @@ public class MySqlStatementParser extends SQLStatementParser { } public SQLStatement parseReset() { - acceptIdentifier("RESET"); + acceptIdentifier(RESET); MySqlResetStatement stmt = new MySqlResetStatement(); @@ -481,7 +511,7 @@ public class MySqlStatementParser extends SQLStatementParser { return true; } - if (identifierEquals("REPLACE")) { + if (identifierEquals(REPLACE)) { MySqlReplaceStatement stmt = parseReplicate(); statementList.add(stmt); return true; @@ -499,18 +529,18 @@ public class MySqlStatementParser extends SQLStatementParser { return true; } - if (identifierEquals("BINLOG")) { + if (identifierEquals(BINLOG)) { SQLStatement stmt = parseBinlog(); statementList.add(stmt); return true; } - if (identifierEquals("RESET")) { + if (identifierEquals(RESET)) { SQLStatement stmt = parseReset(); statementList.add(stmt); return true; } - + if (identifierEquals("HELP")) { lexer.nextToken(); MySqlHelpStatement stmt = new MySqlHelpStatement(); @@ -519,42 +549,42 @@ public class MySqlStatementParser extends SQLStatementParser { return true; } - if (identifierEquals("DESC") || identifierEquals("DESCRIBE")) { + if (identifierEquals(DESC) || identifierEquals(DESCRIBE)) { SQLStatement stmt = parseDescribe(); statementList.add(stmt); return true; } - + if (lexer.token() == Token.LOCK) { lexer.nextToken(); - acceptIdentifier("TABLES"); - + acceptIdentifier(TABLES); + MySqlLockTableStatement stmt = new MySqlLockTableStatement(); stmt.setTableSource(this.exprParser.name()); - - if (identifierEquals("READ")) { + + if (identifierEquals(READ)) { lexer.nextToken(); - if (identifierEquals("LOCAL")) { + if (identifierEquals(LOCAL)) { lexer.nextToken(); stmt.setLockType(LockType.READ_LOCAL); } else { stmt.setLockType(LockType.READ); } - } else if (identifierEquals("WRITE")) { + } else if (identifierEquals(WRITE)) { stmt.setLockType(LockType.WRITE); - } else if (identifierEquals("LOW_PRIORITY")) { + } else if (identifierEquals(LOW_PRIORITY)) { lexer.nextToken(); - acceptIdentifier("WRITE"); + acceptIdentifier(WRITE); stmt.setLockType(LockType.LOW_PRIORITY_WRITE); } - + statementList.add(stmt); return true; } - + if (identifierEquals("UNLOCK")) { lexer.nextToken(); - acceptIdentifier("TABLES"); + acceptIdentifier(TABLES); statementList.add(new MySqlUnlockTablesStatement()); return true; } @@ -562,8 +592,8 @@ public class MySqlStatementParser extends SQLStatementParser { return false; } - public MySqlDescribeStatement parseDescribe() throws ParserException { - if (lexer.token() == Token.DESC || identifierEquals("DESCRIBE")) { + public MySqlDescribeStatement parseDescribe() { + if (lexer.token() == Token.DESC || identifierEquals(DESCRIBE)) { lexer.nextToken(); } else { throw new ParserException("expect DESC, actual " + lexer.token()); @@ -575,7 +605,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - public SQLStatement parseShow() throws ParserException { + public SQLStatement parseShow() { acceptIdentifier("SHOW"); if (lexer.token() == Token.FULL) { @@ -604,7 +634,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - if (identifierEquals("TABLES")) { + if (identifierEquals(TABLES)) { lexer.nextToken(); MySqlShowTablesStatement stmt = parseShowTabless(); @@ -634,7 +664,7 @@ public class MySqlStatementParser extends SQLStatementParser { accept(Token.STAR); accept(Token.RPAREN); - if (identifierEquals("ERRORS")) { + if (identifierEquals(ERRORS)) { lexer.nextToken(); MySqlShowErrorsStatement stmt = new MySqlShowErrorsStatement(); @@ -651,7 +681,7 @@ public class MySqlStatementParser extends SQLStatementParser { } } - if (identifierEquals("ERRORS")) { + if (identifierEquals(ERRORS)) { lexer.nextToken(); MySqlShowErrorsStatement stmt = new MySqlShowErrorsStatement(); @@ -660,7 +690,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - if (identifierEquals("STATUS")) { + if (identifierEquals(STATUS)) { lexer.nextToken(); MySqlShowStatusStatement stmt = parseShowStatus(); @@ -668,7 +698,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - if (identifierEquals("VARIABLES")) { + if (identifierEquals(VARIABLES)) { lexer.nextToken(); MySqlShowVariantsStatement stmt = parseShowVariants(); @@ -676,17 +706,17 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - if (identifierEquals("GLOBAL")) { + if (identifierEquals(GLOBAL)) { lexer.nextToken(); - if (identifierEquals("STATUS")) { + if (identifierEquals(STATUS)) { lexer.nextToken(); MySqlShowStatusStatement stmt = parseShowStatus(); stmt.setGlobal(true); return stmt; } - if (identifierEquals("VARIABLES")) { + if (identifierEquals(VARIABLES)) { lexer.nextToken(); MySqlShowVariantsStatement stmt = parseShowVariants(); stmt.setGlobal(true); @@ -694,17 +724,17 @@ public class MySqlStatementParser extends SQLStatementParser { } } - if (identifierEquals("SESSION")) { + if (identifierEquals(SESSION)) { lexer.nextToken(); - if (identifierEquals("STATUS")) { + if (identifierEquals(STATUS)) { lexer.nextToken(); MySqlShowStatusStatement stmt = parseShowStatus(); stmt.setSession(true); return stmt; } - if (identifierEquals("VARIABLES")) { + if (identifierEquals(VARIABLES)) { lexer.nextToken(); MySqlShowVariantsStatement stmt = parseShowVariants(); stmt.setSession(true); @@ -734,11 +764,11 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); return new MySqlShowMasterLogsStatement(); } - acceptIdentifier("STATUS"); + acceptIdentifier(STATUS); return new MySqlShowMasterStatusStatement(); } - if (identifierEquals("CHARACTER")) { + if (identifierEquals(CHARACTER)) { lexer.nextToken(); accept(Token.SET); MySqlShowCharacterSetStatement stmt = new MySqlShowCharacterSetStatement(); @@ -773,9 +803,9 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - if (identifierEquals("BINLOG")) { + if (identifierEquals(BINLOG)) { lexer.nextToken(); - acceptIdentifier("EVENTS"); + acceptIdentifier(EVENTS); MySqlShowBinLogEventsStatement stmt = new MySqlShowBinLogEventsStatement(); if (lexer.token() == Token.IN) { @@ -860,7 +890,7 @@ public class MySqlStatementParser extends SQLStatementParser { throw new ParserException("TODO " + lexer.stringVal()); } - if (identifierEquals("ENGINE")) { + if (identifierEquals(ENGINE)) { lexer.nextToken(); MySqlShowEngineStatement stmt = new MySqlShowEngineStatement(); stmt.setName(this.exprParser.name()); @@ -871,19 +901,19 @@ public class MySqlStatementParser extends SQLStatementParser { if (identifierEquals("STORAGE")) { lexer.nextToken(); - acceptIdentifier("ENGINES"); + acceptIdentifier(ENGINES); MySqlShowEnginesStatement stmt = new MySqlShowEnginesStatement(); stmt.setStorage(true); return stmt; } - if (identifierEquals("ENGINES")) { + if (identifierEquals(ENGINES)) { lexer.nextToken(); MySqlShowEnginesStatement stmt = new MySqlShowEnginesStatement(); return stmt; } - if (identifierEquals("EVENTS")) { + if (identifierEquals(EVENTS)) { lexer.nextToken(); MySqlShowEventsStatement stmt = new MySqlShowEventsStatement(); @@ -914,7 +944,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - acceptIdentifier("STATUS"); + acceptIdentifier(STATUS); MySqlShowFunctionStatusStatement stmt = new MySqlShowFunctionStatusStatement(); if (lexer.token() == Token.LIKE) { @@ -931,7 +961,7 @@ public class MySqlStatementParser extends SQLStatementParser { // MySqlShowFunctionStatusStatement - if (identifierEquals("ENGINE")) { + if (identifierEquals(ENGINE)) { lexer.nextToken(); MySqlShowEngineStatement stmt = new MySqlShowEngineStatement(); stmt.setName(this.exprParser.name()); @@ -942,13 +972,13 @@ public class MySqlStatementParser extends SQLStatementParser { if (identifierEquals("STORAGE")) { lexer.nextToken(); - acceptIdentifier("ENGINES"); + acceptIdentifier(ENGINES); MySqlShowEnginesStatement stmt = new MySqlShowEnginesStatement(); stmt.setStorage(true); return stmt; } - if (identifierEquals("ENGINES")) { + if (identifierEquals(ENGINES)) { lexer.nextToken(); MySqlShowEnginesStatement stmt = new MySqlShowEnginesStatement(); return stmt; @@ -1006,7 +1036,7 @@ public class MySqlStatementParser extends SQLStatementParser { if (identifierEquals("OPEN")) { lexer.nextToken(); - acceptIdentifier("TABLES"); + acceptIdentifier(TABLES); MySqlShowOpenTablesStatement stmt = new MySqlShowOpenTablesStatement(); if (lexer.token() == Token.FROM || lexer.token() == Token.IN) { @@ -1048,7 +1078,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - acceptIdentifier("STATUS"); + acceptIdentifier(STATUS); MySqlShowProcedureStatusStatement stmt = new MySqlShowProcedureStatusStatement(); if (lexer.token() == Token.LIKE) { @@ -1134,7 +1164,7 @@ public class MySqlStatementParser extends SQLStatementParser { if (identifierEquals("RELAYLOG")) { lexer.nextToken(); - acceptIdentifier("EVENTS"); + acceptIdentifier(EVENTS); MySqlShowRelayLogEventsStatement stmt = new MySqlShowRelayLogEventsStatement(); if (lexer.token() == Token.IN) { @@ -1154,7 +1184,7 @@ public class MySqlStatementParser extends SQLStatementParser { if (identifierEquals("RELAYLOG")) { lexer.nextToken(); - acceptIdentifier("EVENTS"); + acceptIdentifier(EVENTS); MySqlShowRelayLogEventsStatement stmt = new MySqlShowRelayLogEventsStatement(); if (lexer.token() == Token.IN) { @@ -1174,7 +1204,7 @@ public class MySqlStatementParser extends SQLStatementParser { if (identifierEquals("SLAVE")) { lexer.nextToken(); - if (identifierEquals("STATUS")) { + if (identifierEquals(STATUS)) { lexer.nextToken(); return new MySqlShowSlaveStatusStatement(); } else { @@ -1186,7 +1216,7 @@ public class MySqlStatementParser extends SQLStatementParser { if (lexer.token() == Token.TABLE) { lexer.nextToken(); - acceptIdentifier("STATUS"); + acceptIdentifier(STATUS); MySqlShowTableStatusStatement stmt = new MySqlShowTableStatusStatement(); if (lexer.token() == Token.FROM || lexer.token() == Token.IN) { lexer.nextToken(); @@ -1235,7 +1265,7 @@ public class MySqlStatementParser extends SQLStatementParser { throw new ParserException("TODO " + lexer.stringVal()); } - private MySqlShowStatusStatement parseShowStatus() throws ParserException { + private MySqlShowStatusStatement parseShowStatus() { MySqlShowStatusStatement stmt = new MySqlShowStatusStatement(); if (lexer.token() == Token.LIKE) { @@ -1253,7 +1283,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - private MySqlShowVariantsStatement parseShowVariants() throws ParserException { + private MySqlShowVariantsStatement parseShowVariants() { MySqlShowVariantsStatement stmt = new MySqlShowVariantsStatement(); if (lexer.token() == Token.LIKE) { @@ -1271,7 +1301,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - private MySqlShowWarningsStatement parseShowWarnings() throws ParserException { + private MySqlShowWarningsStatement parseShowWarnings() { MySqlShowWarningsStatement stmt = new MySqlShowWarningsStatement(); stmt.setLimit(parseLimit()); @@ -1279,7 +1309,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - private MySqlShowDatabasesStatement parseShowDatabases() throws ParserException { + private MySqlShowDatabasesStatement parseShowDatabases() { MySqlShowDatabasesStatement stmt = new MySqlShowDatabasesStatement(); if (lexer.token() == Token.LIKE) { @@ -1297,7 +1327,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - private MySqlShowTablesStatement parseShowTabless() throws ParserException { + private MySqlShowTablesStatement parseShowTabless() { MySqlShowTablesStatement stmt = new MySqlShowTablesStatement(); if (lexer.token() == Token.FROM) { @@ -1321,7 +1351,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - private MySqlShowColumnsStatement parseShowColumns() throws ParserException { + private MySqlShowColumnsStatement parseShowColumns() { MySqlShowColumnsStatement stmt = new MySqlShowColumnsStatement(); if (lexer.token() == Token.FROM) { @@ -1351,7 +1381,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - public MySqlStartTransactionStatement parseStart() throws ParserException { + public MySqlStartTransactionStatement parseStart() { acceptIdentifier("START"); acceptIdentifier("TRANSACTION"); @@ -1390,28 +1420,28 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); if (lexer.token() == Token.NOT) { lexer.nextToken(); - acceptIdentifier("CHAIN"); + acceptIdentifier(CHAIN); stmt.setChain(Boolean.FALSE); } else { - acceptIdentifier("CHAIN"); + acceptIdentifier(CHAIN); stmt.setChain(Boolean.TRUE); } } - + if (identifierEquals("TO")) { lexer.nextToken(); - + if (identifierEquals("SAVEPOINT")) { lexer.nextToken(); } - + stmt.setTo(this.exprParser.name()); } return stmt; } - public MySqlCommitStatement parseCommit() throws ParserException { + public MySqlCommitStatement parseCommit() { acceptIdentifier("COMMIT"); MySqlCommitStatement stmt = new MySqlCommitStatement(); @@ -1425,10 +1455,10 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); if (lexer.token() == Token.NOT) { lexer.nextToken(); - acceptIdentifier("CHAIN"); + acceptIdentifier(CHAIN); stmt.setChain(Boolean.FALSE); } else { - acceptIdentifier("CHAIN"); + acceptIdentifier(CHAIN); stmt.setChain(Boolean.TRUE); } } @@ -1436,17 +1466,17 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - public MySqlReplaceStatement parseReplicate() throws ParserException { + public MySqlReplaceStatement parseReplicate() { MySqlReplaceStatement stmt = new MySqlReplaceStatement(); - acceptIdentifier("REPLACE"); + acceptIdentifier(REPLACE); - if (identifierEquals("LOW_PRIORITY")) { + if (identifierEquals(LOW_PRIORITY)) { stmt.setLowPriority(true); lexer.nextToken(); } - if (identifierEquals("DELAYED")) { + if (identifierEquals(DELAYED)) { stmt.setDelayed(true); lexer.nextToken(); } @@ -1520,7 +1550,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - protected SQLStatement parseLoad() throws ParserException { + protected SQLStatement parseLoad() { acceptIdentifier("LOAD"); if (identifierEquals("DATA")) { @@ -1536,12 +1566,12 @@ public class MySqlStatementParser extends SQLStatementParser { throw new ParserException("TODO"); } - protected MySqlLoadXmlStatement parseLoadXml() throws ParserException { + protected MySqlLoadXmlStatement parseLoadXml() { acceptIdentifier("XML"); MySqlLoadXmlStatement stmt = new MySqlLoadXmlStatement(); - if (identifierEquals("LOW_PRIORITY")) { + if (identifierEquals(LOW_PRIORITY)) { stmt.setLowPriority(true); lexer.nextToken(); } @@ -1551,7 +1581,7 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); } - if (identifierEquals("LOCAL")) { + if (identifierEquals(LOCAL)) { stmt.setLocal(true); lexer.nextToken(); } @@ -1561,12 +1591,12 @@ public class MySqlStatementParser extends SQLStatementParser { SQLLiteralExpr fileName = (SQLLiteralExpr) exprParser.expr(); stmt.setFileName(fileName); - if (identifierEquals("REPLACE")) { + if (identifierEquals(REPLACE)) { stmt.setReplicate(true); lexer.nextToken(); } - if (identifierEquals("IGNORE")) { + if (identifierEquals(IGNORE)) { stmt.setIgnore(true); lexer.nextToken(); } @@ -1577,7 +1607,7 @@ public class MySqlStatementParser extends SQLStatementParser { SQLName tableName = exprParser.name(); stmt.setTableName(tableName); - if (identifierEquals("CHARACTER")) { + if (identifierEquals(CHARACTER)) { lexer.nextToken(); accept(Token.SET); @@ -1598,7 +1628,7 @@ public class MySqlStatementParser extends SQLStatementParser { stmt.setRowsIdentifiedBy(rowsIdentifiedBy); } - if (identifierEquals("IGNORE")) { + if (identifierEquals(IGNORE)) { throw new ParserException("TODO"); } @@ -1609,12 +1639,12 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - protected MySqlLoadDataInFileStatement parseLoadDataInFile() throws ParserException { + protected MySqlLoadDataInFileStatement parseLoadDataInFile() { acceptIdentifier("DATA"); MySqlLoadDataInFileStatement stmt = new MySqlLoadDataInFileStatement(); - if (identifierEquals("LOW_PRIORITY")) { + if (identifierEquals(LOW_PRIORITY)) { stmt.setLowPriority(true); lexer.nextToken(); } @@ -1624,7 +1654,7 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); } - if (identifierEquals("LOCAL")) { + if (identifierEquals(LOCAL)) { stmt.setLocal(true); lexer.nextToken(); } @@ -1634,12 +1664,12 @@ public class MySqlStatementParser extends SQLStatementParser { SQLLiteralExpr fileName = (SQLLiteralExpr) exprParser.expr(); stmt.setFileName(fileName); - if (identifierEquals("REPLACE")) { + if (identifierEquals(REPLACE)) { stmt.setReplicate(true); lexer.nextToken(); } - if (identifierEquals("IGNORE")) { + if (identifierEquals(IGNORE)) { stmt.setIgnore(true); lexer.nextToken(); } @@ -1650,7 +1680,7 @@ public class MySqlStatementParser extends SQLStatementParser { SQLName tableName = exprParser.name(); stmt.setTableName(tableName); - if (identifierEquals("CHARACTER")) { + if (identifierEquals(CHARACTER)) { lexer.nextToken(); accept(Token.SET); @@ -1671,7 +1701,7 @@ public class MySqlStatementParser extends SQLStatementParser { throw new ParserException("TODO"); } - if (identifierEquals("IGNORE")) { + if (identifierEquals(IGNORE)) { throw new ParserException("TODO"); } @@ -1682,7 +1712,7 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - public MySqlPrepareStatement parsePrepare() throws ParserException { + public MySqlPrepareStatement parsePrepare() { acceptIdentifier("PREPARE"); SQLName name = exprParser.name(); @@ -1692,7 +1722,7 @@ public class MySqlStatementParser extends SQLStatementParser { return new MySqlPrepareStatement(name, from); } - public MySqlExecuteStatement parseExecute() throws ParserException { + public MySqlExecuteStatement parseExecute() { acceptIdentifier("EXECUTE"); MySqlExecuteStatement stmt = new MySqlExecuteStatement(); @@ -1714,12 +1744,12 @@ public class MySqlStatementParser extends SQLStatementParser { if (lexer.token() == Token.INSERT) { lexer.nextToken(); - if (identifierEquals("LOW_PRIORITY")) { + if (identifierEquals(LOW_PRIORITY)) { insertStatement.setLowPriority(true); lexer.nextToken(); } - if (identifierEquals("DELAYED")) { + if (identifierEquals(DELAYED)) { insertStatement.setDelayed(true); lexer.nextToken(); } @@ -1729,7 +1759,7 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); } - if (identifierEquals("IGNORE")) { + if (identifierEquals(IGNORE)) { insertStatement.setIgnore(true); lexer.nextToken(); } @@ -1825,8 +1855,8 @@ public class MySqlStatementParser extends SQLStatementParser { return insertStatement; } - public SQLStatement parseDropUser() throws ParserException { - acceptIdentifier("USER"); + public SQLStatement parseDropUser() { + acceptIdentifier(USER); MySqlDropUser stmt = new MySqlDropUser(); for (;;) { @@ -1849,7 +1879,7 @@ public class MySqlStatementParser extends SQLStatementParser { MySqlDropTableStatement stmt = new MySqlDropTableStatement(); - if (identifierEquals("TEMPORARY")) { + if (identifierEquals(TEMPORARY)) { lexer.nextToken(); stmt.setTemporary(true); } @@ -1872,11 +1902,11 @@ public class MySqlStatementParser extends SQLStatementParser { break; } - if (identifierEquals("RESTRICT")) { - stmt.setOption("RESTRICT"); + if (identifierEquals(RESTRICT)) { + stmt.setOption(RESTRICT); lexer.nextToken(); - } else if (identifierEquals("CASCADE")) { - stmt.setOption("CASCADE"); + } else if (identifierEquals(CASCADE)) { + stmt.setOption(CASCADE); lexer.nextToken(); } @@ -1908,11 +1938,11 @@ public class MySqlStatementParser extends SQLStatementParser { break; } - if (identifierEquals("RESTRICT")) { - stmt.setOption("RESTRICT"); + if (identifierEquals(RESTRICT)) { + stmt.setOption(RESTRICT); lexer.nextToken(); - } else if (identifierEquals("CASCADE")) { - stmt.setOption("CASCADE"); + } else if (identifierEquals(CASCADE)) { + stmt.setOption(CASCADE); lexer.nextToken(); } @@ -1923,14 +1953,14 @@ public class MySqlStatementParser extends SQLStatementParser { return new MySqlSelectParser(this.exprParser); } - public SQLStatement parseSet() throws ParserException { + public SQLStatement parseSet() { accept(Token.SET); Boolean global = null; - if (identifierEquals("GLOBAL")) { + if (identifierEquals(GLOBAL)) { global = Boolean.TRUE; lexer.nextToken(); - } else if (identifierEquals("SESSION")) { + } else if (identifierEquals(SESSION)) { global = Boolean.FALSE; lexer.nextToken(); } @@ -1943,13 +1973,13 @@ public class MySqlStatementParser extends SQLStatementParser { MySqlSetTransactionIsolationLevelStatement stmt = new MySqlSetTransactionIsolationLevelStatement(); stmt.setGlobal(global); - if (identifierEquals("READ")) { + if (identifierEquals(READ)) { lexer.nextToken(); if (identifierEquals("UNCOMMITTED")) { stmt.setLevel("READ UNCOMMITTED"); lexer.nextToken(); - } else if (identifierEquals("WRITE")) { + } else if (identifierEquals(WRITE)) { stmt.setLevel("READ WRITE"); lexer.nextToken(); } else if (identifierEquals("ONLY")) { @@ -1966,7 +1996,7 @@ public class MySqlStatementParser extends SQLStatementParser { lexer.nextToken(); } else if (identifierEquals("REPEATABLE")) { lexer.nextToken(); - if (identifierEquals("READ")) { + if (identifierEquals(READ)) { stmt.setLevel("REPEATABLE READ"); lexer.nextToken(); } else { @@ -1988,7 +2018,7 @@ public class MySqlStatementParser extends SQLStatementParser { String charSet = lexer.stringVal(); stmt.setCharSet(charSet); lexer.nextToken(); - if (identifierEquals("COLLATE")) { + if (identifierEquals(COLLATE2)) { lexer.nextToken(); String collate = lexer.stringVal(); @@ -1997,7 +2027,7 @@ public class MySqlStatementParser extends SQLStatementParser { } } return stmt; - } else if (identifierEquals("CHARACTER")) { + } else if (identifierEquals(CHARACTER)) { lexer.nextToken(); accept(Token.SET); @@ -2010,7 +2040,7 @@ public class MySqlStatementParser extends SQLStatementParser { String charSet = lexer.stringVal(); stmt.setCharSet(charSet); lexer.nextToken(); - if (identifierEquals("COLLATE")) { + if (identifierEquals(COLLATE2)) { lexer.nextToken(); String collate = lexer.stringVal(); @@ -2042,7 +2072,7 @@ public class MySqlStatementParser extends SQLStatementParser { boolean ignore = false; - if (identifierEquals("IGNORE")) { + if (identifierEquals(IGNORE)) { ignore = true; lexer.nextToken(); } @@ -2071,14 +2101,14 @@ public class MySqlStatementParser extends SQLStatementParser { } else if (lexer.token() == Token.INDEX) { lexer.nextToken(); MySqlAlterTableAddIndex item = new MySqlAlterTableAddIndex(); - + if (lexer.token() == Token.LPAREN) { lexer.nextToken(); } else { item.setName(this.exprParser.name()); accept(Token.LPAREN); } - + for (;;) { SQLSelectOrderByItem column = this.exprParser.parseSelectOrderByItem(); item.getItems().add(column); @@ -2094,14 +2124,14 @@ public class MySqlStatementParser extends SQLStatementParser { } else if (lexer.token() == Token.UNIQUE) { lexer.nextToken(); MySqlAlterTableAddUnique item = new MySqlAlterTableAddUnique(); - + if (lexer.token() == Token.LPAREN) { lexer.nextToken(); } else { item.setName(this.exprParser.name()); accept(Token.LPAREN); } - + for (;;) { SQLSelectOrderByItem column = this.exprParser.parseSelectOrderByItem(); item.getItems().add(column); @@ -2118,9 +2148,9 @@ public class MySqlStatementParser extends SQLStatementParser { throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal()); } else if (lexer.token() == Token.CONSTRAINT) { throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal()); - } else if (identifierEquals("FULLTEXT")) { + } else if (identifierEquals(FULLTEXT)) { throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal()); - } else if (identifierEquals("SPATIAL")) { + } else if (identifierEquals(SPATIAL)) { throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal()); } else { MySqlAlterTableAddColumn item = new MySqlAlterTableAddColumn(); @@ -2171,7 +2201,7 @@ public class MySqlStatementParser extends SQLStatementParser { item.setName(stmt.getTableSource().getExpr()); item.setTo(this.exprParser.name()); renameStmt.getItems().add(item); - + return renameStmt; } else if (lexer.token() == Token.ORDER) { throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal()); @@ -2206,15 +2236,15 @@ public class MySqlStatementParser extends SQLStatementParser { throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal()); } else if (identifierEquals("REMOVE")) { throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal()); - } else if (identifierEquals("ENGINE")) { + } else if (identifierEquals(ENGINE)) { lexer.nextToken(); accept(Token.EQ); - stmt.getItems().add(new MySqlAlterTableOption("ENGINE", lexer.stringVal())); + stmt.getItems().add(new MySqlAlterTableOption(ENGINE, lexer.stringVal())); lexer.nextToken(); - } else if (identifierEquals("COLLATE")) { + } else if (identifierEquals(COLLATE2)) { lexer.nextToken(); accept(Token.EQ); - stmt.getItems().add(new MySqlAlterTableOption("COLLATE", lexer.stringVal())); + stmt.getItems().add(new MySqlAlterTableOption(COLLATE2, lexer.stringVal())); lexer.nextToken(); } else if (identifierEquals("PACK_KEYS")) { lexer.nextToken(); @@ -2227,7 +2257,7 @@ public class MySqlStatementParser extends SQLStatementParser { stmt.getItems().add(new MySqlAlterTableOption("PACK_KEYS", lexer.stringVal())); lexer.nextToken(); } - } else if (identifierEquals("CHARACTER")) { + } else if (identifierEquals(CHARACTER)) { lexer.nextToken(); accept(Token.SET); accept(Token.EQ); @@ -2235,7 +2265,7 @@ public class MySqlStatementParser extends SQLStatementParser { item.setCharacterSet(this.exprParser.primary()); if (lexer.token() == Token.COMMA) { lexer.nextToken(); - acceptIdentifier("COLLATE"); + acceptIdentifier(COLLATE2); accept(Token.EQ); item.setCollate(this.exprParser.primary()); } @@ -2243,7 +2273,7 @@ public class MySqlStatementParser extends SQLStatementParser { } else { break; } - + if (lexer.token() == Token.COMMA) { lexer.nextToken(); continue; @@ -2282,21 +2312,21 @@ public class MySqlStatementParser extends SQLStatementParser { return stmt; } - + public SQLStatement parseCreateDatabase() { if (lexer.token() == Token.CREATE) { lexer.nextToken(); } - + accept(Token.DATABASE); - + SQLCreateDatabaseStatement stmt = new SQLCreateDatabaseStatement(); stmt.setName(this.exprParser.name()); - + if (lexer.token() == Token.DEFAULT) { lexer.nextToken(); } - + return stmt; } } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java b/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java index 028921749f..955bdb1ac6 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/mysql/visitor/MySqlOutputVisitor.java @@ -170,9 +170,11 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV print(' '); } - if (SQLSetQuantifier.ALL == x.getDistionOption()) print("ALL "); - else if (SQLSetQuantifier.DISTINCT == x.getDistionOption()) print("DISTINCT "); - else if (SQLSetQuantifier.DISTINCTROW == x.getDistionOption()) { + if (SQLSetQuantifier.ALL == x.getDistionOption()) { + print("ALL "); + } else if (SQLSetQuantifier.DISTINCT == x.getDistionOption()) { + print("DISTINCT "); + } else if (SQLSetQuantifier.DISTINCTROW == x.getDistionOption()) { print("DISTINCTROW "); } @@ -495,7 +497,8 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV print("@@global."); } else { String varName = x.getName(); - if ((!varName.startsWith("@")) && (!varName.equals("?")) && (!varName.startsWith("#")) && (!varName.startsWith("$"))) { + if ((!varName.startsWith("@")) && (!varName.equals("?")) && (!varName.startsWith("#")) + && (!varName.startsWith("$"))) { print("@@"); } } @@ -541,10 +544,10 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV from.accept(this); } - SQLExpr _for = (SQLExpr) x.getAttribute("FOR"); - if (_for != null) { + SQLExpr forExpr = (SQLExpr) x.getAttribute("FOR"); + if (forExpr != null) { print(" FOR "); - _for.accept(this); + forExpr.accept(this); } print(")"); @@ -2568,7 +2571,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV public void endVisit(MySqlAlterTableAddIndex x) { } - + @Override public boolean visit(MySqlAlterTableAddUnique x) { print("ADD "); @@ -2576,9 +2579,9 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV print(x.getType()); print(" "); } - + print("UNIQUE "); - + if (x.getName() != null) { x.getName().accept(this); print(' '); @@ -2586,17 +2589,17 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV print("("); printAndAccept(x.getItems(), ", "); print(")"); - + if (x.getUsing() != null) { print(" USING "); print(x.getUsing()); } return false; } - + @Override public void endVisit(MySqlAlterTableAddUnique x) { - + } @Override diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleCommitStatement.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleCommitStatement.java index bd869a5164..670e9dbe09 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleCommitStatement.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleCommitStatement.java @@ -27,9 +27,7 @@ public class OracleCommitStatement extends OracleStatementImpl { @Override public void accept0(OracleASTVisitor visitor) { - if (visitor.visit(this)) { - - } + visitor.visit(this); visitor.endVisit(this); } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleConstraint.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleConstraint.java index 801de0b555..d41261f41d 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleConstraint.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleConstraint.java @@ -35,8 +35,11 @@ public abstract class OracleConstraint extends OracleSQLObjectImpl { } public void setName(String name) { - if (name == null) this.name = null; - else this.name = new SQLIdentifierExpr(name); + if (name == null) { + this.name = null; + } else { + this.name = new SQLIdentifierExpr(name); + } } public void setName(SQLName name) { diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleSelect.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleSelect.java index 610223a75d..578ee4a47c 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleSelect.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleSelect.java @@ -60,7 +60,9 @@ public class OracleSelect extends SQLSelect { this.query.output(buf); buf.append(" "); - if (this.orderBy != null) this.orderBy.output(buf); + if (this.orderBy != null) { + this.orderBy.output(buf); + } } protected void accept0(SQLASTVisitor visitor) { diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleSelectQueryBlock.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleSelectQueryBlock.java index 8641801335..d26cc5b3e9 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleSelectQueryBlock.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/ast/stmt/OracleSelectQueryBlock.java @@ -30,7 +30,7 @@ public class OracleSelectQueryBlock extends SQLSelectQueryBlock { private static final long serialVersionUID = 1L; - private final List hints = new ArrayList(1); + private final List hints = new ArrayList(1); private OracleSelectHierachicalQueryClause hierachicalQueryClause; private ModelClause modelClause; @@ -93,9 +93,11 @@ public class OracleSelectQueryBlock extends SQLSelectQueryBlock { public void output(StringBuffer buf) { buf.append("SELECT "); - if (SQLSetQuantifier.ALL == this.distionOption) buf.append("ALL "); - else if (SQLSetQuantifier.DISTINCT == this.distionOption) buf.append("DISTINCT "); - else if (SQLSetQuantifier.UNIQUE == this.distionOption) { + if (SQLSetQuantifier.ALL == this.distionOption) { + buf.append("ALL "); + } else if (SQLSetQuantifier.DISTINCT == this.distionOption) { + buf.append("DISTINCT "); + } else if (SQLSetQuantifier.UNIQUE == this.distionOption) { buf.append("UNIQUE "); } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleExprParser.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleExprParser.java index fc6d3e9d76..62d93a6e98 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleExprParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleExprParser.java @@ -91,7 +91,7 @@ public class OracleExprParser extends SQLExprParser { this.lexer.nextToken(); } - public SQLDataType parseDataType() throws ParserException { + public SQLDataType parseDataType() { if (lexer.token() == Token.DEFAULT || lexer.token() == Token.NOT || lexer.token() == Token.NULL) { return null; @@ -127,7 +127,7 @@ public class OracleExprParser extends SQLExprParser { return false; } - public SQLExpr primary() throws ParserException { + public SQLExpr primary() { final Token tok = lexer.token(); SQLExpr sqlExpr = null; @@ -302,7 +302,7 @@ public class OracleExprParser extends SQLExprParser { return super.methodRest(expr, false); } - public SQLExpr primaryRest(SQLExpr expr) throws ParserException { + public SQLExpr primaryRest(SQLExpr expr) { if (lexer.token() == Token.IDENTIFIER && expr instanceof SQLNumericLiteralExpr) { String ident = lexer.stringVal(); if (ident.length() == 1) { @@ -402,8 +402,8 @@ public class OracleExprParser extends SQLExprParser { } if (identifierEquals("AT")) { - char mark_ch = lexer.current(); - int mark_bp = lexer.bp(); + char markChar = lexer.current(); + int markBp = lexer.bp(); lexer.nextToken(); if (lexer.token() == Token.LOCAL) { lexer.nextToken(); @@ -412,7 +412,7 @@ public class OracleExprParser extends SQLExprParser { if (identifierEquals("TIME")) { lexer.nextToken(); } else { - lexer.reset(mark_bp, mark_ch, Token.IDENTIFIER); + lexer.reset(markBp, markChar, Token.IDENTIFIER); return expr; } acceptIdentifier("ZONE"); @@ -619,10 +619,18 @@ public class OracleExprParser extends SQLExprParser { String currentTokenUpperValue = lexer.stringVal(); lexer.nextToken(); - if (currentTokenUpperValue.equals("YEAR")) return OracleIntervalType.YEAR; - if (currentTokenUpperValue.equals("MONTH")) return OracleIntervalType.MONTH; - if (currentTokenUpperValue.equals("HOUR")) return OracleIntervalType.HOUR; - if (currentTokenUpperValue.equals("MINUTE")) return OracleIntervalType.MINUTE; + if (currentTokenUpperValue.equals("YEAR")) { + return OracleIntervalType.YEAR; + } + if (currentTokenUpperValue.equals("MONTH")) { + return OracleIntervalType.MONTH; + } + if (currentTokenUpperValue.equals("HOUR")) { + return OracleIntervalType.HOUR; + } + if (currentTokenUpperValue.equals("MINUTE")) { + return OracleIntervalType.MINUTE; + } if (currentTokenUpperValue.equals("SECOND")) { return OracleIntervalType.SECOND; } @@ -721,7 +729,7 @@ public class OracleExprParser extends SQLExprParser { return interval; } - public SQLExpr relationalRest(SQLExpr expr) throws ParserException { + public SQLExpr relationalRest(SQLExpr expr) { if (lexer.token() == Token.IS) { lexer.nextToken(); @@ -744,7 +752,7 @@ public class OracleExprParser extends SQLExprParser { } - public SQLName name() throws ParserException { + public SQLName name() { SQLName name = super.name(); if (lexer.token() == Token.MONKEYS_AT) { @@ -762,7 +770,7 @@ public class OracleExprParser extends SQLExprParser { return name; } - public SQLExpr equalityRest(SQLExpr expr) throws ParserException { + public SQLExpr equalityRest(SQLExpr expr) { SQLExpr rightExp; if (lexer.token() == Token.EQ) { lexer.nextToken(); @@ -820,7 +828,7 @@ public class OracleExprParser extends SQLExprParser { return column; } - public SQLExpr exprRest(SQLExpr expr) throws ParserException { + public SQLExpr exprRest(SQLExpr expr) { expr = super.exprRest(expr); if (lexer.token() == Token.COLONEQ) { diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleSelectParser.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleSelectParser.java index 33505e2cc2..c75a4eabcc 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleSelectParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleSelectParser.java @@ -72,7 +72,7 @@ import com.alibaba.druid.sql.parser.Token; public class OracleSelectParser extends SQLSelectParser { public OracleSelectParser(String sql){ - super (new OracleExprParser(sql)); + super(new OracleExprParser(sql)); } public OracleSelectParser(SQLExprParser exprParser){ @@ -194,8 +194,9 @@ public class OracleSelectParser extends SQLSelectParser { if (identifierEquals("READ")) { lexer.nextToken(); - if (identifierEquals("ONLY")) lexer.nextToken(); - else { + if (identifierEquals("ONLY")) { + lexer.nextToken(); + } else { throw new ParserException("syntax error"); } @@ -203,8 +204,9 @@ public class OracleSelectParser extends SQLSelectParser { } else if (lexer.token() == (Token.CHECK)) { lexer.nextToken(); - if (identifierEquals("OPTION")) lexer.nextToken(); - else { + if (identifierEquals("OPTION")) { + lexer.nextToken(); + } else { throw new ParserException("syntax error"); } @@ -348,7 +350,6 @@ public class OracleSelectParser extends SQLSelectParser { model.setReturnRowsClause(returnRowsClause); } - while (identifierEquals("REFERENCE")) { ReferenceModelClause referenceModelClause = new ReferenceModelClause(); lexer.nextToken(); @@ -619,7 +620,7 @@ public class OracleSelectParser extends SQLSelectParser { } } - protected String as() throws ParserException { + protected String as() { if (lexer.token() == Token.CONNECT) { return null; } @@ -685,7 +686,7 @@ public class OracleSelectParser extends SQLSelectParser { if (lexer.token() == (Token.LPAREN)) { lexer.nextToken(); OracleSelectSubqueryTableSource tableSource; - if (lexer.token() == Token.SELECT) { + if (lexer.token() == Token.SELECT || lexer.token() == Token.WITH) { tableSource = new OracleSelectSubqueryTableSource(select()); } else if (lexer.token() == (Token.LPAREN)) { tableSource = new OracleSelectSubqueryTableSource(select()); @@ -965,7 +966,9 @@ public class OracleSelectParser extends SQLSelectParser { item.setAlias(as()); pivot.getItems().add(item); - if (!(lexer.token() == (Token.COMMA))) break; + if (!(lexer.token() == (Token.COMMA))) { + break; + } lexer.nextToken(); } @@ -977,7 +980,9 @@ public class OracleSelectParser extends SQLSelectParser { pivot.getPivotFor().add(new SQLIdentifierExpr(lexer.stringVal())); lexer.nextToken(); - if (!(lexer.token() == (Token.COMMA))) break; + if (!(lexer.token() == (Token.COMMA))) { + break; + } lexer.nextToken(); } @@ -1047,7 +1052,9 @@ public class OracleSelectParser extends SQLSelectParser { unPivot.getPivotFor().add(new SQLIdentifierExpr(lexer.stringVal())); lexer.nextToken(); - if (!(lexer.token() == (Token.COMMA))) break; + if (!(lexer.token() == (Token.COMMA))) { + break; + } lexer.nextToken(); } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleStatementParser.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleStatementParser.java index 3dcab87096..04e5f86ad5 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleStatementParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleStatementParser.java @@ -130,11 +130,11 @@ public class OracleStatementParser extends SQLStatementParser { } @Override - public void parseStatementList(List statementList) throws ParserException { + public void parseStatementList(List statementList) { parseStatementList(statementList, -1); } - public void parseStatementList(List statementList, int max) throws ParserException { + public void parseStatementList(List statementList, int max) { for (;;) { if (max != -1) { if (statementList.size() >= max) { @@ -1106,7 +1106,7 @@ public class OracleStatementParser extends SQLStatementParser { return new OracleSelectParser(this.exprParser); } - public OracleMergeStatement parseMerge() throws ParserException { + public OracleMergeStatement parseMerge() { accept(Token.MERGE); OracleMergeStatement stmt = new OracleMergeStatement(); @@ -1410,7 +1410,7 @@ public class OracleStatementParser extends SQLStatementParser { return stmt; } - public OracleDeleteStatement parseDeleteStatement() throws ParserException { + public OracleDeleteStatement parseDeleteStatement() { OracleDeleteStatement deleteStatement = new OracleDeleteStatement(); if (lexer.token() == Token.DELETE) { @@ -1595,7 +1595,7 @@ public class OracleStatementParser extends SQLStatementParser { return stmt; } - public SQLUpdateStatement parseUpdateStatement() throws ParserException { + public SQLUpdateStatement parseUpdateStatement() { return new OracleUpdateParser(this.lexer).parseUpdateStatement(); } } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleUpdateParser.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleUpdateParser.java index 8823527839..2859c2801e 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleUpdateParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleUpdateParser.java @@ -27,7 +27,7 @@ import com.alibaba.druid.sql.parser.Token; public class OracleUpdateParser extends SQLStatementParser { - public OracleUpdateParser(String sql) throws ParserException{ + public OracleUpdateParser(String sql) { super(new OracleExprParser(sql)); } @@ -35,7 +35,7 @@ public class OracleUpdateParser extends SQLStatementParser { super(new OracleExprParser(lexer)); } - public OracleUpdateStatement parseUpdateStatement() throws ParserException { + public OracleUpdateStatement parseUpdateStatement() { OracleUpdateStatement update = new OracleUpdateStatement(); if (lexer.token() == Token.UPDATE) { @@ -66,11 +66,13 @@ public class OracleUpdateParser extends SQLStatementParser { return update; } - private void parseErrorLoging(OracleUpdateStatement update) throws ParserException { - if (identifierEquals("LOG")) throw new ParserException("TODO"); + private void parseErrorLoging(OracleUpdateStatement update) { + if (identifierEquals("LOG")) { + throw new ParserException("TODO"); + } } - private void parseReturn(OracleUpdateStatement update) throws ParserException { + private void parseReturn(OracleUpdateStatement update) { if (identifierEquals("RETURN") || lexer.token() == Token.RETURNING) { lexer.nextToken(); @@ -102,20 +104,20 @@ public class OracleUpdateParser extends SQLStatementParser { } } - private void parseHints(OracleUpdateStatement update) throws ParserException { + private void parseHints(OracleUpdateStatement update) { if (lexer.token() == Token.HINT) { throw new ParserException("TODO"); } } - private void parseWhere(OracleUpdateStatement update) throws ParserException { + private void parseWhere(OracleUpdateStatement update) { if (lexer.token() == (Token.WHERE)) { lexer.nextToken(); update.setWhere(this.exprParser.expr()); } } - private void parseSet(OracleUpdateStatement update) throws ParserException { + private void parseSet(OracleUpdateStatement update) { accept(Token.SET); for (;;) { diff --git a/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGExprParser.java b/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGExprParser.java index 714c0e2c11..da82e8deba 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGExprParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGExprParser.java @@ -20,12 +20,11 @@ import com.alibaba.druid.sql.dialect.postgresql.ast.PGAggregateExpr; import com.alibaba.druid.sql.dialect.postgresql.ast.PGOrderBy; import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGAnalytic; import com.alibaba.druid.sql.parser.Lexer; -import com.alibaba.druid.sql.parser.ParserException; import com.alibaba.druid.sql.parser.SQLExprParser; import com.alibaba.druid.sql.parser.Token; public class PGExprParser extends SQLExprParser{ - public PGExprParser(String sql) throws ParserException{ + public PGExprParser(String sql) { super(new PGLexer(sql)); this.lexer.nextToken(); } @@ -34,7 +33,7 @@ public class PGExprParser extends SQLExprParser{ super(lexer); } - protected SQLAggregateExpr parseAggregateExpr(String methodName) throws ParserException { + protected SQLAggregateExpr parseAggregateExpr(String methodName) { methodName = methodName.toUpperCase(); PGAggregateExpr aggregateExpr; @@ -73,9 +72,9 @@ public class PGExprParser extends SQLExprParser{ over.setOrderBy(parseOrderBy()); - if (over.getOrderBy() != null) { - //TODO window - } + // if (over.getOrderBy() != null) { + // //TODO window + // } accept(Token.RPAREN); aggregateExpr.setOver(over); diff --git a/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGSQLStatementParser.java b/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGSQLStatementParser.java index 7a5ff5ec38..c0c3cd4c47 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGSQLStatementParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGSQLStatementParser.java @@ -40,7 +40,7 @@ import com.alibaba.druid.sql.parser.Token; public class PGSQLStatementParser extends SQLStatementParser { - public PGSQLStatementParser(String sql) throws ParserException{ + public PGSQLStatementParser(String sql) { super (new PGExprParser(sql)); } @@ -52,7 +52,7 @@ public class PGSQLStatementParser extends SQLStatementParser { return new PGSelectParser(this.exprParser); } - public SQLUpdateStatement parseUpdateStatement() throws ParserException { + public SQLUpdateStatement parseUpdateStatement() { accept(Token.UPDATE); PGUpdateStatement udpateStatement = new PGUpdateStatement(); @@ -150,7 +150,7 @@ public class PGSQLStatementParser extends SQLStatementParser { return stmt; } - public PGDeleteStatement parseDeleteStatement() throws ParserException { + public PGDeleteStatement parseDeleteStatement() { lexer.nextToken(); PGDeleteStatement deleteStatement = new PGDeleteStatement(); @@ -329,7 +329,7 @@ public class PGSQLStatementParser extends SQLStatementParser { return withQuery; } - public PGSelectStatement parseSelect() throws ParserException { + public PGSelectStatement parseSelect() { return new PGSelectStatement(createSQLSelectParser().select()); } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGSelectParser.java b/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGSelectParser.java index 3eb5c6b20b..ea8ba54d86 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGSelectParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/postgresql/parser/PGSelectParser.java @@ -38,7 +38,7 @@ public class PGSelectParser extends SQLSelectParser { super(exprParser); } - public PGSelectParser(String sql) throws ParserException{ + public PGSelectParser(String sql) { this(new PGExprParser(sql)); } @@ -47,7 +47,7 @@ public class PGSelectParser extends SQLSelectParser { } @Override - public SQLSelectQuery query() throws ParserException { + public SQLSelectQuery query() { PGSelectQueryBlock queryBlock = new PGSelectQueryBlock(); if (lexer.token() == Token.SELECT) { @@ -147,9 +147,6 @@ public class PGSelectParser extends SQLSelectParser { if (lexer.token() == Token.ROW || lexer.token() == Token.ROWS) { lexer.nextToken(); - } else { - // TODO - // throw new ParserException("expect 'ROW' or 'ROWS'"); } } @@ -222,7 +219,7 @@ public class PGSelectParser extends SQLSelectParser { return queryRest(queryBlock); } - protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) throws ParserException { + protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) { if (lexer.token() == Token.AS && tableSource instanceof SQLExprTableSource) { String alias = this.as(); diff --git a/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/ast/Top.java b/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/ast/Top.java index 577b16a113..0a4e258c82 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/ast/Top.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/ast/Top.java @@ -55,9 +55,8 @@ public class Top extends SQLServerObjectImpl { @Override public void accept0(SQLServerASTVisitor visitor) { - if (visitor.visit(this)) { - - } + visitor.visit(this); + visitor.endVisit(this); } } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/ast/expr/SQLServerObjectReferenceExpr.java b/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/ast/expr/SQLServerObjectReferenceExpr.java index 2f1522a33a..113c9b4ed9 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/ast/expr/SQLServerObjectReferenceExpr.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/ast/expr/SQLServerObjectReferenceExpr.java @@ -60,9 +60,7 @@ public class SQLServerObjectReferenceExpr extends SQLServerObjectImpl implements @Override public void accept0(SQLServerASTVisitor visitor) { - if (visitor.visit(this)) { - - } + visitor.visit(this); visitor.endVisit(this); } diff --git a/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/parser/SQLServerExprParser.java b/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/parser/SQLServerExprParser.java index 43f699df5d..5c58cb8c91 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/parser/SQLServerExprParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/parser/SQLServerExprParser.java @@ -20,7 +20,6 @@ import com.alibaba.druid.sql.ast.SQLName; import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr; import com.alibaba.druid.sql.dialect.sqlserver.ast.expr.SQLServerObjectReferenceExpr; import com.alibaba.druid.sql.parser.Lexer; -import com.alibaba.druid.sql.parser.ParserException; import com.alibaba.druid.sql.parser.SQLExprParser; import com.alibaba.druid.sql.parser.Token; @@ -30,12 +29,12 @@ public class SQLServerExprParser extends SQLExprParser { super(lexer); } - public SQLServerExprParser(String sql) throws ParserException{ + public SQLServerExprParser(String sql) { super(new SQLServerLexer(sql)); this.lexer.nextToken(); } - public SQLExpr primaryRest(SQLExpr expr) throws ParserException { + public SQLExpr primaryRest(SQLExpr expr) { if (lexer.token() == Token.DOTDOT) { expr = nameRest((SQLName) expr); } @@ -43,7 +42,7 @@ public class SQLServerExprParser extends SQLExprParser { return super.primaryRest(expr); } - public SQLName nameRest(SQLName expr) throws ParserException { + public SQLName nameRest(SQLName expr) { if (lexer.token() == Token.DOTDOT) { lexer.nextToken(); String text = lexer.stringVal(); diff --git a/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/parser/SQLServerSelectParser.java b/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/parser/SQLServerSelectParser.java index 9a06a3ce4f..6fae0bb0ad 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/parser/SQLServerSelectParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/sqlserver/parser/SQLServerSelectParser.java @@ -21,7 +21,6 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectQuery; import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelect; import com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerSelectQueryBlock; import com.alibaba.druid.sql.dialect.sqlserver.ast.Top; -import com.alibaba.druid.sql.parser.ParserException; import com.alibaba.druid.sql.parser.SQLExprParser; import com.alibaba.druid.sql.parser.SQLSelectParser; import com.alibaba.druid.sql.parser.Token; @@ -36,7 +35,7 @@ public class SQLServerSelectParser extends SQLSelectParser { super(exprParser); } - public SQLSelect select() throws ParserException { + public SQLSelect select() { SQLServerSelect select = new SQLServerSelect(); select.setQuery(query()); @@ -49,7 +48,7 @@ public class SQLServerSelectParser extends SQLSelectParser { return select; } - public SQLSelectQuery query() throws ParserException { + public SQLSelectQuery query() { if (lexer.token() == Token.LPAREN) { lexer.nextToken(); diff --git a/src/main/java/com/alibaba/druid/sql/parser/Lexer.java b/src/main/java/com/alibaba/druid/sql/parser/Lexer.java index de8fe9813d..e4aa41f831 100644 --- a/src/main/java/com/alibaba/druid/sql/parser/Lexer.java +++ b/src/main/java/com/alibaba/druid/sql/parser/Lexer.java @@ -178,12 +178,6 @@ public class Lexer { token = ERROR; } - /** - * Report an error at the current token position using the provided arguments. - */ - private void lexError(String key, Object... args) { - lexError(tokenPos, key, args); - } /** * Return the current token, set by nextToken(). @@ -376,7 +370,7 @@ public class Lexer { token = EOF; tokenPos = bp = eofPos; } else { - lexError("illegal.char", String.valueOf((int) ch)); + lexError(tokenPos, "illegal.char", String.valueOf((int) ch)); scanChar(); } @@ -814,7 +808,7 @@ public class Lexer { token = Token.LITERAL_HEX; } - public String hexString() throws NumberFormatException { + public String hexString() { return new String(buf, np, sp); } @@ -882,7 +876,7 @@ public class Lexer { } // QS_TODO negative number is invisible for lexer - public Number integerValue() throws NumberFormatException { + public Number integerValue() { long result = 0; boolean negative = false; int i = np, max = np + sp; @@ -941,9 +935,9 @@ public class Lexer { return this.ch; } - public void reset(int mark, char mark_ch, Token token) { + public void reset(int mark, char markChar, Token token) { this.bp = mark; - this.ch = mark_ch; + this.ch = markChar; this.token = token; } diff --git a/src/main/java/com/alibaba/druid/sql/parser/SQLDDLParser.java b/src/main/java/com/alibaba/druid/sql/parser/SQLDDLParser.java index e86e8b86b8..8b7e703cf9 100644 --- a/src/main/java/com/alibaba/druid/sql/parser/SQLDDLParser.java +++ b/src/main/java/com/alibaba/druid/sql/parser/SQLDDLParser.java @@ -15,7 +15,6 @@ */ package com.alibaba.druid.sql.parser; -import com.alibaba.druid.sql.ast.SQLName; import com.alibaba.druid.sql.ast.statement.SQLTableConstaint; public class SQLDDLParser extends SQLStatementParser { @@ -29,13 +28,13 @@ public class SQLDDLParser extends SQLStatementParser { } protected SQLTableConstaint parseConstraint() { - SQLName name = null; if (lexer.token() == Token.CONSTRAINT) { lexer.nextToken(); } if (lexer.token() == Token.IDENTIFIER) { - name = this.exprParser.name(); + this.exprParser.name(); + throw new ParserException("TODO"); } if (lexer.token() == Token.PRIMARY) { @@ -45,10 +44,6 @@ public class SQLDDLParser extends SQLStatementParser { throw new ParserException("TODO"); } - if (name != null) { - - } - throw new ParserException("TODO"); } } diff --git a/src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java b/src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java index db84ba1050..d4317e3e32 100644 --- a/src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java +++ b/src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java @@ -67,7 +67,7 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; public class SQLExprParser extends SQLParser { - public SQLExprParser(String sql) throws ParserException{ + public SQLExprParser(String sql){ super(sql); } @@ -75,7 +75,7 @@ public class SQLExprParser extends SQLParser { super(lexer); } - public SQLExpr expr() throws ParserException { + public SQLExpr expr() { if (lexer.token() == Token.STAR) { lexer.nextToken(); @@ -91,7 +91,7 @@ public class SQLExprParser extends SQLParser { return exprRest(expr); } - public SQLExpr exprRest(SQLExpr expr) throws ParserException { + public SQLExpr exprRest(SQLExpr expr) { expr = bitXorRest(expr); expr = multiplicativeRest(expr); expr = additiveRest(expr); @@ -107,12 +107,12 @@ public class SQLExprParser extends SQLParser { return expr; } - public final SQLExpr bitXor() throws ParserException { + public final SQLExpr bitXor() { SQLExpr expr = primary(); return bitXorRest(expr); } - public SQLExpr bitXorRest(SQLExpr expr) throws ParserException { + public SQLExpr bitXorRest(SQLExpr expr) { if (lexer.token() == Token.CARET) { lexer.nextToken(); SQLExpr rightExp = primary(); @@ -123,12 +123,12 @@ public class SQLExprParser extends SQLParser { return expr; } - public final SQLExpr multiplicative() throws ParserException { + public final SQLExpr multiplicative() { SQLExpr expr = primary(); return multiplicativeRest(expr); } - public SQLExpr multiplicativeRest(SQLExpr expr) throws ParserException { + public SQLExpr multiplicativeRest(SQLExpr expr) { if (lexer.token() == Token.STAR) { lexer.nextToken(); SQLExpr rightExp = bitXor(); @@ -148,7 +148,7 @@ public class SQLExprParser extends SQLParser { return expr; } - public SQLExpr primary() throws ParserException { + public SQLExpr primary() { SQLExpr sqlExpr = null; final Token tok = lexer.token(); @@ -458,7 +458,7 @@ public class SQLExprParser extends SQLParser { return new SQLSelectParser(this); } - public SQLExpr primaryRest(SQLExpr expr) throws ParserException { + public SQLExpr primaryRest(SQLExpr expr) { if (expr == null) { throw new IllegalArgumentException("expr"); } @@ -499,20 +499,20 @@ public class SQLExprParser extends SQLParser { } if (expr instanceof SQLName || expr instanceof SQLDefaultExpr) { - String method_name; + String methodName; SQLMethodInvokeExpr methodInvokeExpr; if (expr instanceof SQLPropertyExpr) { - method_name = ((SQLPropertyExpr) expr).getName(); - methodInvokeExpr = new SQLMethodInvokeExpr(method_name); + methodName = ((SQLPropertyExpr) expr).getName(); + methodInvokeExpr = new SQLMethodInvokeExpr(methodName); methodInvokeExpr.setOwner(((SQLPropertyExpr) expr).getOwner()); } else { - method_name = expr.toString(); - methodInvokeExpr = new SQLMethodInvokeExpr(method_name); + methodName = expr.toString(); + methodInvokeExpr = new SQLMethodInvokeExpr(methodName); } - if (isAggreateFunction(method_name)) { - SQLAggregateExpr aggregateExpr = parseAggregateExpr(method_name); + if (isAggreateFunction(methodName)) { + SQLAggregateExpr aggregateExpr = parseAggregateExpr(methodName); return aggregateExpr; } @@ -573,11 +573,11 @@ public class SQLExprParser extends SQLParser { return expr; } - public final SQLExpr groupComparisionRest(SQLExpr expr) throws ParserException { + public final SQLExpr groupComparisionRest(SQLExpr expr) { return expr; } - public final void names(Collection exprCol) throws ParserException { + public final void names(Collection exprCol) { if (lexer.token() == Token.RBRACE) { return; } @@ -594,7 +594,7 @@ public class SQLExprParser extends SQLParser { } } - public final void exprList(Collection exprCol) throws ParserException { + public final void exprList(Collection exprCol) { if (lexer.token() == Token.RPAREN || lexer.token() == Token.RBRACKET) { return; } @@ -613,7 +613,7 @@ public class SQLExprParser extends SQLParser { } } - public SQLName name() throws ParserException { + public SQLName name() { String identName; if (lexer.token() == Token.LITERAL_ALIAS) { identName = '"' + lexer.stringVal() + '"'; @@ -636,7 +636,7 @@ public class SQLExprParser extends SQLParser { return name; } - public SQLName nameRest(SQLName name) throws ParserException { + public SQLName nameRest(SQLName name) { if (lexer.token() == Token.DOT) { lexer.nextToken(); @@ -664,10 +664,10 @@ public class SQLExprParser extends SQLParser { } public boolean isAggreateFunction(String word) { - String[] _aggregateFunctions = { "AVG", "COUNT", "MAX", "MIN", "STDDEV", "SUM" }; + String[] aggregateFunctions = { "AVG", "COUNT", "MAX", "MIN", "STDDEV", "SUM" }; - for (int i = 0; i < _aggregateFunctions.length; ++i) { - if (_aggregateFunctions[i].compareToIgnoreCase(word) == 0) { + for (int i = 0; i < aggregateFunctions.length; ++i) { + if (aggregateFunctions[i].compareToIgnoreCase(word) == 0) { return true; } } @@ -675,7 +675,7 @@ public class SQLExprParser extends SQLParser { return false; } - protected SQLAggregateExpr parseAggregateExpr(String methodName) throws ParserException { + protected SQLAggregateExpr parseAggregateExpr(String methodName) { methodName = methodName.toUpperCase(); SQLAggregateExpr aggregateExpr; @@ -696,7 +696,7 @@ public class SQLExprParser extends SQLParser { return aggregateExpr; } - public SQLOrderBy parseOrderBy() throws ParserException { + public SQLOrderBy parseOrderBy() { if (lexer.token() == Token.ORDER) { SQLOrderBy orderBy = new SQLOrderBy(); @@ -717,7 +717,7 @@ public class SQLExprParser extends SQLParser { return null; } - public SQLSelectOrderByItem parseSelectOrderByItem() throws ParserException { + public SQLSelectOrderByItem parseSelectOrderByItem() { SQLSelectOrderByItem item = new SQLSelectOrderByItem(); item.setExpr(expr()); @@ -733,12 +733,12 @@ public class SQLExprParser extends SQLParser { return item; } - public final SQLExpr bitAnd() throws ParserException { + public final SQLExpr bitAnd() { SQLExpr expr = shift(); return bitAndRest(expr); } - public final SQLExpr bitAndRest(SQLExpr expr) throws ParserException { + public final SQLExpr bitAndRest(SQLExpr expr) { while (lexer.token() == Token.AMP) { lexer.nextToken(); SQLExpr rightExp = shift(); @@ -747,12 +747,12 @@ public class SQLExprParser extends SQLParser { return expr; } - public final SQLExpr bitOr() throws ParserException { + public final SQLExpr bitOr() { SQLExpr expr = bitAnd(); return bitOrRest(expr); } - public final SQLExpr bitOrRest(SQLExpr expr) throws ParserException { + public final SQLExpr bitOrRest(SQLExpr expr) { if (lexer.token() == Token.BAR) { lexer.nextToken(); SQLExpr rightExp = bitAnd(); @@ -767,12 +767,12 @@ public class SQLExprParser extends SQLParser { return expr; } - public final SQLExpr equality() throws ParserException { + public final SQLExpr equality() { SQLExpr expr = shift(); return equalityRest(expr); } - public SQLExpr equalityRest(SQLExpr expr) throws ParserException { + public SQLExpr equalityRest(SQLExpr expr) { SQLExpr rightExp; if (lexer.token() == Token.EQ) { lexer.nextToken(); @@ -797,7 +797,7 @@ public class SQLExprParser extends SQLParser { return expr; } - public final SQLExpr inRest(SQLExpr expr) throws ParserException { + public final SQLExpr inRest(SQLExpr expr) { if (lexer.token() == Token.IN) { lexer.nextToken(); accept(Token.LPAREN); @@ -823,12 +823,12 @@ public class SQLExprParser extends SQLParser { return expr; } - public final SQLExpr additive() throws ParserException { + public final SQLExpr additive() { SQLExpr expr = multiplicative(); return additiveRest(expr); } - public SQLExpr additiveRest(SQLExpr expr) throws ParserException { + public SQLExpr additiveRest(SQLExpr expr) { if (lexer.token() == Token.PLUS) { lexer.nextToken(); SQLExpr rightExp = multiplicative(); @@ -851,12 +851,12 @@ public class SQLExprParser extends SQLParser { return expr; } - public final SQLExpr shift() throws ParserException { + public final SQLExpr shift() { SQLExpr expr = additive(); return shiftRest(expr); } - public SQLExpr shiftRest(SQLExpr expr) throws ParserException { + public SQLExpr shiftRest(SQLExpr expr) { if (lexer.token() == Token.LTLT) { lexer.nextToken(); SQLExpr rightExp = additive(); @@ -874,12 +874,12 @@ public class SQLExprParser extends SQLParser { return expr; } - public SQLExpr and() throws ParserException { + public SQLExpr and() { SQLExpr expr = relational(); return andRest(expr); } - public SQLExpr andRest(SQLExpr expr) throws ParserException { + public SQLExpr andRest(SQLExpr expr) { for (;;) { if (lexer.token() == Token.AND || lexer.token() == Token.AMPAMP) { lexer.nextToken(); @@ -894,12 +894,12 @@ public class SQLExprParser extends SQLParser { return expr; } - public SQLExpr or() throws ParserException { + public SQLExpr or() { SQLExpr expr = and(); return orRest(expr); } - public SQLExpr orRest(SQLExpr expr) throws ParserException { + public SQLExpr orRest(SQLExpr expr) { for (;;) { if (lexer.token() == Token.OR) { @@ -920,24 +920,24 @@ public class SQLExprParser extends SQLParser { return expr; } - public SQLExpr relational() throws ParserException { + public SQLExpr relational() { SQLExpr expr = equality(); return relationalRest(expr); } - public SQLExpr relationalRest(SQLExpr expr) throws ParserException { + public SQLExpr relationalRest(SQLExpr expr) { SQLExpr rightExp; if (lexer.token() == Token.LT) { SQLBinaryOperator op = SQLBinaryOperator.LessThan; - + lexer.nextToken(); if (lexer.token() == Token.EQ) { lexer.nextToken(); op = SQLBinaryOperator.LessThanOrEqual; } - + rightExp = bitOr(); expr = new SQLBinaryOpExpr(expr, op, rightExp); // expr = relationalRest(expr); @@ -1086,7 +1086,7 @@ public class SQLExprParser extends SQLParser { return expr; } - public SQLDataType parseDataType() throws ParserException { + public SQLDataType parseDataType() { if (lexer.token() == Token.DEFAULT || lexer.token() == Token.NOT || lexer.token() == Token.NULL) { return null; diff --git a/src/main/java/com/alibaba/druid/sql/parser/SQLParser.java b/src/main/java/com/alibaba/druid/sql/parser/SQLParser.java index 2434890423..0f4ea9da03 100644 --- a/src/main/java/com/alibaba/druid/sql/parser/SQLParser.java +++ b/src/main/java/com/alibaba/druid/sql/parser/SQLParser.java @@ -45,7 +45,7 @@ public class SQLParser { } } - protected String as() throws ParserException { + protected String as() { String alias = null; if (lexer.token() == Token.AS) { diff --git a/src/main/java/com/alibaba/druid/sql/parser/SQLSelectParser.java b/src/main/java/com/alibaba/druid/sql/parser/SQLSelectParser.java index 17e56e411a..f758edd7c2 100644 --- a/src/main/java/com/alibaba/druid/sql/parser/SQLSelectParser.java +++ b/src/main/java/com/alibaba/druid/sql/parser/SQLSelectParser.java @@ -46,7 +46,7 @@ public class SQLSelectParser extends SQLParser { this.exprParser = exprParser; } - public SQLSelect select() throws ParserException { + public SQLSelect select() { SQLSelect select = new SQLSelect(); select.setQuery(query()); @@ -72,7 +72,7 @@ public class SQLSelectParser extends SQLParser { return union; } - public SQLSelectQuery queryRest(SQLSelectQuery selectQuery) throws ParserException { + public SQLSelectQuery queryRest(SQLSelectQuery selectQuery) { if (lexer.token() == Token.UNION) { lexer.nextToken(); @@ -123,7 +123,7 @@ public class SQLSelectParser extends SQLParser { return selectQuery; } - public SQLSelectQuery query() throws ParserException { + public SQLSelectQuery query() { if (lexer.token() == Token.LPAREN) { lexer.nextToken(); @@ -159,7 +159,7 @@ public class SQLSelectParser extends SQLParser { return queryRest(queryBlock); } - protected void parseWhere(SQLSelectQueryBlock queryBlock) throws ParserException { + protected void parseWhere(SQLSelectQueryBlock queryBlock) { if (lexer.token() == Token.WHERE) { lexer.nextToken(); @@ -167,7 +167,7 @@ public class SQLSelectParser extends SQLParser { } } - protected void parseGroupBy(SQLSelectQueryBlock queryBlock) throws ParserException { + protected void parseGroupBy(SQLSelectQueryBlock queryBlock) { if (lexer.token() == Token.GROUP) { lexer.nextToken(); accept(Token.BY); @@ -198,7 +198,7 @@ public class SQLSelectParser extends SQLParser { } } - protected void parseSelectList(SQLSelectQueryBlock queryBlock) throws ParserException { + protected void parseSelectList(SQLSelectQueryBlock queryBlock) { queryBlock.getSelectList().add(new SQLSelectItem(expr(), as())); while (lexer.token() == Token.COMMA) { @@ -207,7 +207,7 @@ public class SQLSelectParser extends SQLParser { } } - public void parseFrom(SQLSelectQueryBlock queryBlock) throws ParserException { + public void parseFrom(SQLSelectQueryBlock queryBlock) { if (lexer.token() != Token.FROM) { return; } @@ -217,7 +217,7 @@ public class SQLSelectParser extends SQLParser { queryBlock.setFrom(parseTableSource()); } - public SQLTableSource parseTableSource() throws ParserException { + public SQLTableSource parseTableSource() { if (lexer.token() == Token.LPAREN) { lexer.nextToken(); SQLTableSource tableSource; @@ -248,7 +248,7 @@ public class SQLSelectParser extends SQLParser { return parseTableSourceRest(tableReference); } - private void parseTableSourceQueryTableExpr(SQLExprTableSource tableReference) throws ParserException { + private void parseTableSourceQueryTableExpr(SQLExprTableSource tableReference) { if (lexer.token() == Token.LITERAL_ALIAS || lexer.token() == Token.IDENTIFIED || lexer.token() == Token.LITERAL_CHARS) { tableReference.setExpr(this.exprParser.name()); @@ -258,7 +258,7 @@ public class SQLSelectParser extends SQLParser { tableReference.setExpr(expr()); } - protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) throws ParserException { + protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) { if ((tableSource.getAlias() == null) || (tableSource.getAlias().length() == 0)) { if (lexer.token() != Token.LEFT && lexer.token() != Token.RIGHT && lexer.token() != Token.FULL) { String alias = as(); @@ -329,7 +329,7 @@ public class SQLSelectParser extends SQLParser { return this.exprParser.expr(); } - public SQLOrderBy parseOrderBy() throws ParserException { + public SQLOrderBy parseOrderBy() { return this.exprParser.parseOrderBy(); } diff --git a/src/main/java/com/alibaba/druid/sql/parser/SQLStatementParser.java b/src/main/java/com/alibaba/druid/sql/parser/SQLStatementParser.java index 02632ca53e..62a465e046 100644 --- a/src/main/java/com/alibaba/druid/sql/parser/SQLStatementParser.java +++ b/src/main/java/com/alibaba/druid/sql/parser/SQLStatementParser.java @@ -63,13 +63,13 @@ public class SQLStatementParser extends SQLParser { return exprParser; } - public List parseStatementList() throws ParserException { + public List parseStatementList() { List statementList = new ArrayList(); parseStatementList(statementList); return statementList; } - public void parseStatementList(List statementList) throws ParserException { + public void parseStatementList(List statementList) { for (;;) { if (lexer.token() == Token.EOF) { return; @@ -201,11 +201,11 @@ public class SQLStatementParser extends SQLParser { } if (lexer.token() == Token.LPAREN) { - char mark_ch = lexer.current(); - int mark_bp = lexer.bp(); + char markChar = lexer.current(); + int markBp = lexer.bp(); lexer.nextToken(); if (lexer.token() == Token.SELECT) { - lexer.reset(mark_bp, mark_ch, Token.LPAREN); + lexer.reset(markBp, markChar, Token.LPAREN); SQLStatement stmt = parseSelect(); statementList.add(stmt); continue; @@ -408,11 +408,11 @@ public class SQLStatementParser extends SQLParser { return false; } - public SQLStatement parseDropUser() throws ParserException { + public SQLStatement parseDropUser() { throw new ParserException("TODO " + lexer.token()); } - public SQLStatement parseDropIndex() throws ParserException { + public SQLStatement parseDropIndex() { accept(Token.INDEX); SQLDropIndexStatement stmt = new SQLDropIndexStatement(); stmt.setIndexName(this.exprParser.name()); @@ -421,7 +421,7 @@ public class SQLStatementParser extends SQLParser { return stmt; } - public SQLCallStatement parseCall() throws ParserException { + public SQLCallStatement parseCall() { boolean brace = false; if (lexer.token() == Token.LBRACE) { @@ -447,7 +447,7 @@ public class SQLStatementParser extends SQLParser { return stmt; } - public SQLStatement parseSet() throws ParserException { + public SQLStatement parseSet() { accept(Token.SET); SQLSetStatement stmt = new SQLSetStatement(); @@ -470,9 +470,9 @@ public class SQLStatementParser extends SQLParser { } } - public SQLStatement parseCreate() throws ParserException { - char mark_ch = lexer.current(); - int mark_bp = lexer.bp(); + public SQLStatement parseCreate() { + char markChar = lexer.current(); + int markBp = lexer.bp(); accept(Token.CREATE); @@ -489,7 +489,7 @@ public class SQLStatementParser extends SQLParser { lexer.nextToken(); acceptIdentifier("REPLACE"); if (lexer.token() == Token.PROCEDURE) { - lexer.reset(mark_bp, mark_ch, Token.CREATE); + lexer.reset(markBp, markChar, Token.CREATE); return parseCreateProcedure(); } @@ -530,7 +530,7 @@ public class SQLStatementParser extends SQLParser { return new SQLCreateTableParser(this.exprParser); } - public SQLSelectStatement parseSelect() throws ParserException { + public SQLSelectStatement parseSelect() { return new SQLSelectStatement(createSQLSelectParser().select()); } @@ -538,7 +538,7 @@ public class SQLStatementParser extends SQLParser { return new SQLSelectParser(this.exprParser); } - public SQLUpdateStatement parseUpdateStatement() throws ParserException { + public SQLUpdateStatement parseUpdateStatement() { SQLUpdateStatement udpateStatement = createUpdateStatement(); if (lexer.token() == Token.UPDATE) { @@ -578,7 +578,7 @@ public class SQLStatementParser extends SQLParser { return new SQLUpdateStatement(); } - public SQLDeleteStatement parseDeleteStatement() throws ParserException { + public SQLDeleteStatement parseDeleteStatement() { SQLDeleteStatement deleteStatement = new SQLDeleteStatement(); if (lexer.token() == Token.DELETE) { @@ -601,13 +601,13 @@ public class SQLStatementParser extends SQLParser { return deleteStatement; } - public SQLCreateTableStatement parseCreateTable() throws ParserException { + public SQLCreateTableStatement parseCreateTable() { // SQLCreateTableParser parser = new SQLCreateTableParser(this.lexer); // return parser.parseCrateTable(); throw new ParserException("TODO"); } - public SQLCreateViewStatement parseCreateView() throws ParserException { + public SQLCreateViewStatement parseCreateView() { SQLCreateViewStatement createView = new SQLCreateViewStatement(); this.accept(Token.CREATE); diff --git a/src/main/java/com/alibaba/druid/sql/parser/SymbolTable.java b/src/main/java/com/alibaba/druid/sql/parser/SymbolTable.java index 5509acaaf9..cad0e3a081 100644 --- a/src/main/java/com/alibaba/druid/sql/parser/SymbolTable.java +++ b/src/main/java/com/alibaba/druid/sql/parser/SymbolTable.java @@ -27,14 +27,18 @@ public class SymbolTable { /** Default table size. */ public static final int DEFAULT_TABLE_SIZE = 128; + public static final int MAX_SIZE = 1024; + /** Buckets. */ private final Entry[] buckets; private final String[] symbols; - private final char[][] symbols_char; + private final char[][] symbolsChar; // actual table size private final int indexMask; + private int size = 0; + // // Constructors // @@ -49,7 +53,7 @@ public class SymbolTable { this.indexMask = tableSize - 1; this.buckets = new Entry[tableSize]; this.symbols = new String[tableSize]; - this.symbols_char = new char[tableSize][]; + this.symbolsChar = new char[tableSize][]; } // @@ -97,7 +101,7 @@ public class SymbolTable { if (sym != null) { if (sym.length() == len) { - char[] characters = symbols_char[bucket]; + char[] characters = symbolsChar[bucket]; for (int i = 0; i < len; i++) { if (buffer[offset + i] != characters[i]) { @@ -125,14 +129,19 @@ public class SymbolTable { return entry.symbol; } } + + if (size >= MAX_SIZE) { + return new String(buffer, offset, len); + } // add new entry Entry entry = new Entry(buffer, offset, len, hash, buckets[bucket]); buckets[bucket] = entry; if (match) { symbols[bucket] = entry.symbol; - symbols_char[bucket] = entry.characters; + symbolsChar[bucket] = entry.characters; } + size++; return entry.symbol; } // addSymbol(char[],int,int):String diff --git a/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java b/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java index 3ea42f7244..658f336a38 100644 --- a/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java @@ -187,8 +187,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter { } public void printIndent() { - for (int i = 0; i < this.indentCount; ++i) + for (int i = 0; i < this.indentCount; ++i) { print(this.indent); + } } public void println() { @@ -245,7 +246,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter { for (int i = groupList.size() - 1; i >= 0; --i) { SQLExpr item = groupList.get(i); visitBinaryLeft(item, x.getOperator()); - + if (relational) { println(); } else { @@ -255,7 +256,6 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter { print(" "); } - visitorBinaryRight(x); if (isRoot && relational) { @@ -376,8 +376,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter { } public boolean visit(SQLExistsExpr x) { - if (x.isNot()) print("NOT EXISTS ("); - else { + if (x.isNot()) { + print("NOT EXISTS ("); + } else { print("EXISTS ("); } incrementIndent(); @@ -426,12 +427,12 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter { public boolean visit(SQLAggregateExpr x) { print(x.getMethodName()); print("("); - + if (x.getOption() != null) { print(x.getOption().toString()); print(' '); } - + printAndAccept(x.getArguments(), ", "); print(")"); return false; @@ -1123,7 +1124,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter { print("*/"); return false; } - + @Override public boolean visit(SQLCreateDatabaseStatement x) { print("CREATE DATABASE "); diff --git a/src/main/java/com/alibaba/druid/sql/visitor/SQLEvalVisitorUtils.java b/src/main/java/com/alibaba/druid/sql/visitor/SQLEvalVisitorUtils.java index b43ae3d959..f74248d20a 100644 --- a/src/main/java/com/alibaba/druid/sql/visitor/SQLEvalVisitorUtils.java +++ b/src/main/java/com/alibaba/druid/sql/visitor/SQLEvalVisitorUtils.java @@ -19,7 +19,6 @@ import static com.alibaba.druid.sql.visitor.SQLEvalVisitor.EVAL_VALUE; import java.math.BigDecimal; import java.math.BigInteger; -import java.math.RoundingMode; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -32,7 +31,6 @@ import com.alibaba.druid.sql.SQLUtils; import com.alibaba.druid.sql.ast.SQLExpr; import com.alibaba.druid.sql.ast.SQLObject; import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr; -import com.alibaba.druid.sql.ast.expr.SQLBinaryOperator; import com.alibaba.druid.sql.ast.expr.SQLCharExpr; import com.alibaba.druid.sql.ast.expr.SQLNumericLiteralExpr; import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr; @@ -64,7 +62,7 @@ public class SQLEvalVisitorUtils { return sqlObject.getAttributes().get(EVAL_VALUE); } - + public static Object eval(String dbType, SQLObject sqlObject, List parameters) { return eval(dbType, sqlObject, parameters, true); } @@ -88,15 +86,15 @@ public class SQLEvalVisitorUtils { if (JdbcUtils.MYSQL.equals(dbType)) { return new MySqlEvalVisitorImpl(); } - + if (JdbcUtils.H2.equals(dbType)) { return new MySqlEvalVisitorImpl(); } - + if (JdbcUtils.ORACLE.equals(dbType)) { return new OracleEvalVisitor(); } - + if (JdbcUtils.POSTGRESQL.equals(dbType)) { return new PGEvalVisitor(); } @@ -121,9 +119,42 @@ public class SQLEvalVisitorUtils { return false; } - if (SQLBinaryOperator.Add.equals(x.getOperator())) { - Object value = _add(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); - x.putAttribute(EVAL_VALUE, value); + Object value = null; + switch (x.getOperator()) { + case Add: + value = _add(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); + x.putAttribute(EVAL_VALUE, value); + break; + case Subtract: + value = _sub(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); + x.putAttribute(EVAL_VALUE, value); + break; + case Multiply: + value = _multi(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); + x.putAttribute(EVAL_VALUE, value); + break; + case Divide: + value = _div(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); + x.putAttribute(EVAL_VALUE, value); + break; + case GreaterThan: + value = _gt(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); + x.putAttribute(EVAL_VALUE, value); + break; + case GreaterThanOrEqual: + value = _gteq(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); + x.putAttribute(EVAL_VALUE, value); + break; + case LessThan: + value = _lt(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); + x.putAttribute(EVAL_VALUE, value); + break; + case LessThanOrEqual: + value = _lteq(x.getLeft().getAttribute(EVAL_VALUE), x.getRight().getAttributes().get(EVAL_VALUE)); + x.putAttribute(EVAL_VALUE, value); + break; + default: + break; } return false; @@ -133,9 +164,9 @@ public class SQLEvalVisitorUtils { if (!"?".equals(x.getName())) { return false; } - + Map attributes = x.getAttributes(); - + int varIndex = x.getIndex(); if (varIndex != -1 && visitor.getParameters().size() > varIndex) { @@ -299,7 +330,7 @@ public class SQLEvalVisitorUtils { try { return new SimpleDateFormat(format).parse(text); } catch (ParseException e) { - throw new DruidRuntimeException("format : " + format + ", value : " + text); + throw new DruidRuntimeException("format : " + format + ", value : " + text, e); } } @@ -368,21 +399,6 @@ public class SQLEvalVisitorUtils { return null; } - BigDecimal decimalA = _decimal(a); - BigDecimal decimalB = _decimal(b); - - try { - return decimalA.divide(decimalB); - } catch (ArithmeticException ex) { - return decimalA.divide(decimalB, 4, RoundingMode.CEILING); - } - } - - public static Object _div2(Object a, Object b) { - if (a == null || b == null) { - return null; - } - if (a instanceof BigDecimal || b instanceof BigDecimal) { return _decimal(a).divide(_decimal(b)); } @@ -607,6 +623,14 @@ public class SQLEvalVisitorUtils { if (a instanceof BigInteger || b instanceof BigInteger) { return _bigInt(a).add(_bigInt(b)); } + + if (a instanceof Double || b instanceof Double) { + return _double(a) + _double(b); + } + + if (a instanceof Float || b instanceof Float) { + return _float(a) + _float(b); + } if (a instanceof Long || b instanceof Long) { return _long(a) + _long(b); @@ -647,6 +671,14 @@ public class SQLEvalVisitorUtils { if (a instanceof BigInteger || b instanceof BigInteger) { return _bigInt(a).subtract(_bigInt(b)); } + + if (a instanceof Double || b instanceof Double) { + return _double(a) - _double(b); + } + + if (a instanceof Float || b instanceof Float) { + return _float(a) - _float(b); + } if (a instanceof Long || b instanceof Long) { return _long(a) - _long(b); diff --git a/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java b/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java index 1fe690de1a..61782a2484 100644 --- a/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java @@ -218,8 +218,6 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { } public boolean visit(SQLIdentifierExpr x) { - String currentTable = getCurrentTable(); - if (subQueryMap.containsKey(currentTable)) { return false; } @@ -252,13 +250,13 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { public void addOrderByColumn(String table, String columnName, SQLObject expr) { Column column = new Column(table, columnName); - + SQLObject parent = expr.getParent(); if (parent instanceof SQLSelectOrderByItem) { SQLOrderingSpecification type = ((SQLSelectOrderByItem) parent).getType(); column.getAttributes().put("orderBy.type", type); } - + orderByColumns.add(column); } } @@ -421,12 +419,10 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { String column = ((SQLIdentifierExpr) expr).getName(); String table = getCurrentTable(); - if (table != null) { - if (aliasMap.containsKey(table)) { - table = aliasMap.get(table); - if (table == null) { - return null; - } + if (table != null && aliasMap.containsKey(table)) { + table = aliasMap.get(table); + if (table == null) { + return null; } } @@ -548,14 +544,12 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { return false; } - if (x.getInto() != null) { - if (x.getInto().getExpr() instanceof SQLName) { - SQLName into = (SQLName) x.getInto().getExpr(); - String ident = into.toString(); - TableStat stat = getTableStat(ident); - if (stat != null) { - stat.incrementInsertCount(); - } + if (x.getInto() != null && x.getInto().getExpr() instanceof SQLName) { + SQLName into = (SQLName) x.getInto().getExpr(); + String ident = into.toString(); + TableStat stat = getTableStat(ident); + if (stat != null) { + stat.incrementInsertCount(); } } @@ -746,11 +740,9 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { SQLSelectQuery query = x.getSelect().getQuery(); Map aliasMap = getAliasMap(); - if (aliasMap != null) { - if (x.getAlias() != null) { - aliasMap.put(x.getAlias(), null); - subQueryMap.put(x.getAlias(), query); - } + if (aliasMap != null && x.getAlias() != null) { + aliasMap.put(x.getAlias(), null); + subQueryMap.put(x.getAlias(), query); } return false; } @@ -911,7 +903,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { } public void endVisit(SQLDeleteStatement x) { - + } public void endVisit(SQLUpdateStatement x) { diff --git a/src/main/java/com/alibaba/druid/stat/DruidStatManagerFacade.java b/src/main/java/com/alibaba/druid/stat/DruidStatManagerFacade.java index fbf6e386f8..7c9cfb9bfe 100644 --- a/src/main/java/com/alibaba/druid/stat/DruidStatManagerFacade.java +++ b/src/main/java/com/alibaba/druid/stat/DruidStatManagerFacade.java @@ -45,7 +45,7 @@ import com.alibaba.druid.util.StringUtils; * * @author sandzhang */ -public class DruidStatManagerFacade { +public final class DruidStatManagerFacade { private final static DruidStatManagerFacade instance = new DruidStatManagerFacade(); private boolean resetEnable = true; @@ -133,9 +133,13 @@ public class DruidStatManagerFacade { return null; } - public List> getSqlStatDataList() { + public List> getSqlStatDataList(Integer dataSourceId) { List> result = new ArrayList>(); for (Object datasource : getDruidDataSourceInstances()) { + if (dataSourceId != null && dataSourceId.intValue() != System.identityHashCode(datasource)) { + continue; + } + for (Object sqlStat : DruidDataSourceUtils.getSqlStatMap(datasource).values()) { Map data = JdbcSqlStatUtils.getData(sqlStat); @@ -179,7 +183,9 @@ public class DruidStatManagerFacade { List> traceList = new ArrayList>(); for (Object dataSource : getDruidDataSourceInstances()) { List stacks = ((DruidDataSource) dataSource).getActiveConnectionStackTrace(); - traceList.add(stacks); + if (stacks.size() > 0 ) { + traceList.add(stacks); + } } return traceList; } diff --git a/src/main/java/com/alibaba/druid/stat/DruidStatService.java b/src/main/java/com/alibaba/druid/stat/DruidStatService.java index 3e38805d60..1b510e0804 100644 --- a/src/main/java/com/alibaba/druid/stat/DruidStatService.java +++ b/src/main/java/com/alibaba/druid/stat/DruidStatService.java @@ -44,7 +44,7 @@ import com.alibaba.druid.util.StringUtils; * * @author sandzhang */ -public class DruidStatService implements DruidStatServiceMBean { +public final class DruidStatService implements DruidStatServiceMBean { private final static Log LOG = LogFactory.getLog(DruidStatService.class); @@ -79,7 +79,7 @@ public class DruidStatService implements DruidStatServiceMBean { public String service(String url) { - Map parameters = StringUtils.getParameters(url); + Map parameters = getParameters(url); if (url.equals("/basic.json")) { return returnJSONResult(RESULT_CODE_SUCCESS, statManagerFacade.returnJSONBasicStat()); @@ -138,7 +138,7 @@ public class DruidStatService implements DruidStatServiceMBean { if (url.startsWith("/webapp.json")) { return returnJSONResult(RESULT_CODE_SUCCESS, getWebAppStatDataList(parameters)); } - + if (url.startsWith("/websession.json")) { return returnJSONResult(RESULT_CODE_SUCCESS, getWebSessionStatDataList(parameters)); } @@ -187,7 +187,7 @@ public class DruidStatService implements DruidStatServiceMBean { List> array = WebAppStatManager.getInstance().getSessionStatData(); return comparatorOrderBy(array, parameters); } - + private List> getWebAppStatDataList(Map parameters) { List> array = WebAppStatManager.getInstance().getWebAppStatData(); return comparatorOrderBy(array, parameters); @@ -195,11 +195,14 @@ public class DruidStatService implements DruidStatServiceMBean { private List> comparatorOrderBy(List> array, Map parameters) { // when open the stat page before executing some sql - if (array == null || array.isEmpty()) return null; + if (array == null || array.isEmpty()) { + return null; + } // when parameters is null String orderBy, orderType = null; - Integer page, perPageCount = null; + Integer page = DEFAULT_PAGE; + Integer perPageCount = DEFAULT_PER_PAGE_COUNT; if (parameters == null) { orderBy = DEFAULT_ORDER_TYPE; orderType = DEFAULT_ORDER_TYPE; @@ -208,17 +211,23 @@ public class DruidStatService implements DruidStatServiceMBean { } else { orderBy = parameters.get("orderBy"); orderType = parameters.get("orderType"); - page = Integer.parseInt(parameters.get("page")); - perPageCount = Integer.parseInt(parameters.get("perPageCount")); + String pageParam = parameters.get("page"); + if (pageParam != null && pageParam.length() != 0) { + page = Integer.parseInt(pageParam); + } + String pageCountParam = parameters.get("perPageCount"); + if (pageCountParam != null && pageCountParam.length() > 0) { + perPageCount = Integer.parseInt(pageCountParam); + } } // others,such as order orderBy = orderBy == null ? DEFAULT_ORDERBY : orderBy; orderType = orderType == null ? DEFAULT_ORDER_TYPE : orderType; - page = page == null ? DEFAULT_PAGE : page; - perPageCount = perPageCount == null ? DEFAULT_PER_PAGE_COUNT : perPageCount; - if (!"desc".equals(orderType)) orderType = DEFAULT_ORDER_TYPE; + if (!"desc".equals(orderType)) { + orderType = DEFAULT_ORDER_TYPE; + } // orderby the statData array if (orderBy != null && orderBy.trim().length() != 0) { @@ -228,14 +237,24 @@ public class DruidStatService implements DruidStatServiceMBean { // page int fromIndex = (page - 1) * perPageCount; int toIndex = page * perPageCount; - if (toIndex > array.size()) toIndex = array.size(); + if (toIndex > array.size()) { + toIndex = array.size(); + } return array.subList(fromIndex, toIndex); } private List> getSqlStatDataList(Map parameters) { - List> array = statManagerFacade.getSqlStatDataList(); - return comparatorOrderBy(array, parameters); + Integer dataSourceId = null; + + String dataSourceIdParam = parameters.get("dataSourceId"); + if (dataSourceIdParam != null && dataSourceIdParam.length() > 0) { + dataSourceId = Integer.parseInt(dataSourceIdParam); + } + + List> array = statManagerFacade.getSqlStatDataList(dataSourceId); + List> sortedArray = comparatorOrderBy(array, parameters); + return sortedArray; } private String getSqlStat(Integer id) { @@ -310,4 +329,29 @@ public class DruidStatService implements DruidStatServiceMBean { } } + public static Map getParameters(String url) { + if (url == null || (url = url.trim()).length() == 0) { + return Collections. emptyMap(); + } + + String parametersStr = StringUtils.subString(url, "?", null); + if (parametersStr == null || parametersStr.length() == 0) { + return Collections. emptyMap(); + } + + String[] parametersArray = parametersStr.split("&"); + Map parameters = new LinkedHashMap(); + + for (String parameterStr : parametersArray) { + int index = parameterStr.indexOf("="); + if (index <= 0) { + continue; + } + + String name = parameterStr.substring(0, index); + String value = parameterStr.substring(index + 1); + parameters.put(name, value); + } + return parameters; + } } diff --git a/src/main/java/com/alibaba/druid/stat/JdbcDataSourceStat.java b/src/main/java/com/alibaba/druid/stat/JdbcDataSourceStat.java index a61281c526..3c95692c58 100644 --- a/src/main/java/com/alibaba/druid/stat/JdbcDataSourceStat.java +++ b/src/main/java/com/alibaba/druid/stat/JdbcDataSourceStat.java @@ -68,6 +68,8 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean { private final AtomicLong clobOpenCount = new AtomicLong(); + private final AtomicLong blobOpenCount = new AtomicLong(); + public JdbcDataSourceStat(String name, String url){ this(name, url, null); } @@ -101,6 +103,7 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean { } public void reset() { + blobOpenCount.set(0); clobOpenCount.set(0); connectionStat.reset(); @@ -318,4 +321,12 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean { clobOpenCount.incrementAndGet(); } + public long getBlobOpenCount() { + return blobOpenCount.get(); + } + + public void incrementBlobOpenCount() { + blobOpenCount.incrementAndGet(); + } + } diff --git a/src/main/java/com/alibaba/druid/stat/JdbcSqlStat.java b/src/main/java/com/alibaba/druid/stat/JdbcSqlStat.java index 5dcdfaf0aa..15ecc98457 100644 --- a/src/main/java/com/alibaba/druid/stat/JdbcSqlStat.java +++ b/src/main/java/com/alibaba/druid/stat/JdbcSqlStat.java @@ -76,6 +76,12 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { private boolean removed = false; private final AtomicLong clobOpenCount = new AtomicLong(); + private final AtomicLong blobOpenCount = new AtomicLong(); + private final AtomicLong readStringLength = new AtomicLong(); + private final AtomicLong readBytesLength = new AtomicLong(); + + private final AtomicLong inputStreamOpenCount = new AtomicLong(); + private final AtomicLong readerOpenCount = new AtomicLong(); private final Histogram histogram = new Histogram(new long[] { // // @@ -223,7 +229,12 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { updateCountHistogram.reset(); executeAndResultHoldTimeHistogram.reset(); + blobOpenCount.set(0); clobOpenCount.set(0); + readStringLength.set(0); + readBytesLength.set(0); + inputStreamOpenCount.set(0); + readerOpenCount.set(0); } public long getConcurrentMax() { @@ -240,7 +251,9 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { } for (;;) { long max = updateCountMax.get(); - if (delta <= max) break; + if (delta <= max) { + break; + } if (updateCountMax.compareAndSet(max, delta)) { break; } @@ -273,6 +286,46 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { clobOpenCount.incrementAndGet(); } + public long getBlobOpenCount() { + return blobOpenCount.get(); + } + + public void incrementBlobOpenCount() { + blobOpenCount.incrementAndGet(); + } + + public long getReadStringLength() { + return readStringLength.get(); + } + + public void addStringReadLength(long length) { + this.readStringLength.addAndGet(length); + } + + public long getReadBytesLength() { + return readBytesLength.get(); + } + + public void addReadBytesLength(long length) { + this.readBytesLength.addAndGet(length); + } + + public long getReaderOpenCount() { + return readerOpenCount.get(); + } + + public void addReaderOpenCount(int count) { + this.readerOpenCount.addAndGet(count); + } + + public long getInputStreamOpenCount() { + return inputStreamOpenCount.get(); + } + + public void addInputStreamOpenCount(int count) { + this.inputStreamOpenCount.addAndGet(count); + } + public long getId() { return id; } @@ -315,7 +368,9 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { this.fetchRowCount.addAndGet(delta); for (;;) { long max = fetchRowCountMax.get(); - if (delta <= max) break; + if (delta <= max) { + break; + } if (fetchRowCountMax.compareAndSet(max, delta)) { break; } @@ -394,7 +449,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { long current = executeSpanNanoMax.get(); if (current < nanoSpan) { if (executeSpanNanoMax.compareAndSet(current, nanoSpan)) { - // 可能不准确,但是绝大多数情况下都会正确,性能换取一致性 + // 可能不准确,但是绝大多数情况下都会正确,性能换取一致性 executeNanoSpanMaxOccurTime = System.currentTimeMillis(); break; @@ -489,10 +544,16 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { SimpleType.LONG, // new ArrayType(SimpleType.LONG, true), // - // 30 - + // 30 - 34 + new ArrayType(SimpleType.LONG, true), // + new ArrayType(SimpleType.LONG, true), // + SimpleType.LONG, // + SimpleType.LONG, // + SimpleType.LONG, // - new ArrayType(SimpleType.LONG, true), // - new ArrayType(SimpleType.LONG, true), // + // 35 - + SimpleType.LONG, // + SimpleType.LONG, // SimpleType.LONG, // SimpleType.LONG, // SimpleType.LONG, // @@ -549,6 +610,13 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { "FetchRowCountMax", // "ClobOpenCount", + // 35 - + "BlobOpenCount", // + "ReadStringLength", // + "ReadBytesLength", // + "InputStreamOpenCount", // + "ReaderOpenCount", // + // }; String[] indexDescriptions = indexNames; @@ -620,6 +688,12 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean { map.put("FetchRowCountMax", getFetchRowCountMax()); // 33 map.put("ClobOpenCount", getClobOpenCount()); // 34 + map.put("BlobOpenCount", getBlobOpenCount()); // 35 + map.put("ReadStringLength", getReadStringLength()); // 36 + map.put("ReadBytesLength", getReadBytesLength()); // 37 + map.put("InputStreamOpenCount", getInputStreamOpenCount()); // 38 + map.put("ReaderOpenCount", getReaderOpenCount()); // 39 + return map; } diff --git a/src/main/java/com/alibaba/druid/stat/JdbcStatManager.java b/src/main/java/com/alibaba/druid/stat/JdbcStatManager.java index 386462d736..6cd73b3653 100644 --- a/src/main/java/com/alibaba/druid/stat/JdbcStatManager.java +++ b/src/main/java/com/alibaba/druid/stat/JdbcStatManager.java @@ -34,7 +34,7 @@ import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.proxy.DruidDriver; import com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl; -public class JdbcStatManager implements JdbcStatManagerMBean { +public final class JdbcStatManager implements JdbcStatManagerMBean { private final AtomicLong sqlIdSeed = new AtomicLong(1000); diff --git a/src/main/java/com/alibaba/druid/support/console/DruidStat.java b/src/main/java/com/alibaba/druid/support/console/DruidStat.java index 73f207764d..aca6aa9ccb 100644 --- a/src/main/java/com/alibaba/druid/support/console/DruidStat.java +++ b/src/main/java/com/alibaba/druid/support/console/DruidStat.java @@ -15,6 +15,7 @@ */ package com.alibaba.druid.support.console; +import java.util.ArrayList; import java.io.File; import java.io.IOException; import java.util.List; @@ -61,29 +62,55 @@ public class DruidStat { @SuppressWarnings("all") public static void printDruidStat(Option option) throws Exception { - String address = loadManagementAgentAndGetAddress(option.getVmid()); + String address = loadManagementAgentAndGetAddress(option.getPid()); JMXServiceURL jmxUrl = new JMXServiceURL(address); JMXConnector jmxc = JMXConnectorFactory.connect(jmxUrl); MBeanServerConnection jmxConn = jmxc.getMBeanServerConnection(); - - if (option.printSqlData()) { - List> content = (List>) invokeService(jmxConn, Option.SQL); - TabledDataPrinter.printSqlData(content, option); - } if (option.printDataSourceData()) { List> content = (List>) invokeService(jmxConn, Option.DATA_SOURCE); TabledDataPrinter.printDataSourceData(content, option); } + + if (option.printSqlData()) { + List> content = (List>) invokeService(jmxConn, Option.SQL); + if (content == null ) { + System.out.println("无SqlStat统计数据,请检查是否已执行了SQL"); + } else { + TabledDataPrinter.printSqlData(content, option); + } + } + if (option.printActiveConn()) { List> content = (List>) invokeService(jmxConn, Option.ACTIVE_CONN); - TabledDataPrinter.printActiveConnStack(content, option); + if (content == null || content.size() == 0 ) { + System.out.println("目前无活动中的数据库连接"); + } else { + TabledDataPrinter.printActiveConnStack(content, option); + } } } @SuppressWarnings("all") - private static Object invokeService(MBeanServerConnection jmxConn, int dataType) throws Exception { + public static List getDataSourceIds(Option option) throws Exception{ + String address = loadManagementAgentAndGetAddress(option.getPid()); + JMXServiceURL jmxUrl = new JMXServiceURL(address); + JMXConnector jmxc = JMXConnectorFactory.connect(jmxUrl); + MBeanServerConnection jmxConn = jmxc.getMBeanServerConnection(); + List> content = (List>) invokeService(jmxConn, Option.DATA_SOURCE); + TabledDataPrinter.printDataSourceData(content, option); + + List result = new ArrayList(); + for (Map dsStat : content) { + Integer id = (Integer)dsStat.get("Identity"); + result.add(id); + } + return result; + } + + @SuppressWarnings("all") + public static Object invokeService(MBeanServerConnection jmxConn, int dataType) throws Exception { String url = Option.getUrl(dataType); ObjectName name = new ObjectName(DruidStatService.MBEAN_NAME); String result = (String) jmxConn.invoke(name, "service", new String[] { url }, new String[] { String.class.getName() }); @@ -98,9 +125,7 @@ public class DruidStat { try { vm = VirtualMachine.attach(name); } catch (AttachNotSupportedException x) { - IOException ioe = new IOException(x.getMessage()); - ioe.initCause(x); - throw ioe; + throw new IOException(x.getMessage(), x); } String home = vm.getSystemProperties().getProperty("java.home"); @@ -122,13 +147,9 @@ public class DruidStat { try { vm.loadAgent(agent, "com.sun.management.jmxremote"); } catch (AgentLoadException x) { - IOException ioe = new IOException(x.getMessage()); - ioe.initCause(x); - throw ioe; + throw new IOException(x.getMessage(), x); } catch (AgentInitializationException x) { - IOException ioe = new IOException(x.getMessage()); - ioe.initCause(x); - throw ioe; + throw new IOException(x.getMessage(), x); } // get the connector address diff --git a/src/main/java/com/alibaba/druid/support/console/Option.java b/src/main/java/com/alibaba/druid/support/console/Option.java index bf59ef4e54..b358f26792 100644 --- a/src/main/java/com/alibaba/druid/support/console/Option.java +++ b/src/main/java/com/alibaba/druid/support/console/Option.java @@ -17,22 +17,24 @@ package com.alibaba.druid.support.console; public class Option { - public static enum PrintStyle {HORIZONTAL , VERTICAL }; public static final int DATA_SOURCE = 1 ; public static final int SQL = 2 ; public static final int ACTIVE_CONN = 4 ; - private PrintStyle style = PrintStyle.HORIZONTAL; private int printDataType = 0; - private int vmid = -1; + private int pid = -1; private int id = -1; + private int interval = -1; + private boolean detailPrint; public void addPrintDataType(int newValue) { this.printDataType= this.printDataType | newValue; } public static boolean isPrintHelp(String[] args) { - if (args == null ) return true; + if (args == null ) { + return true; + } for (String arg: args) { if (arg.equals("-help") ) { return true; @@ -55,18 +57,12 @@ public class Option { return this.printDataType; } - public void setStyle(PrintStyle style) { - this.style=style; - } - public PrintStyle getStyle() { - return this.style; - } - public void setVmid(int vmid) { - this.vmid=vmid; + public void setPid(int pid) { + this.pid=pid; } - public int getVmid() { - return this.vmid; + public int getPid() { + return this.pid; } public static String getUrl(int dataType) { @@ -82,6 +78,15 @@ public class Option { } } + private static int parsePositiveInt(String v) { + try { + int pid = Integer.parseInt(v); + return pid; + } catch (NumberFormatException e) { + return -1; + } + } + public static Option parseOptions(String[] args) throws OptionParseException{ Option option = new Option(); int i = 0; @@ -90,57 +95,87 @@ public class Option { } while (i < args.length) { - if ( i == args.length -1 ) { - if (args[i].startsWith("-")) throw new OptionParseException("please specify vmid in last arguments!"); - try { - int vmid = Integer.parseInt(args[i]); - option.setVmid(vmid); - } catch (NumberFormatException e) { - throw new OptionParseException("vmid argument is not a integer!"); - } - } - if (!args[i].startsWith("-")) { - i++; - continue; - } + int v1 = parsePositiveInt(args[i]); + + //check last two arguments + if ( (i == args.length - 2) && v1 > 0) { + int v2 = parsePositiveInt(args[i+1]); + if ( v2 > 0) { + option.setPid(v1); + option.setInterval(v2); + } else { + throw new OptionParseException("请在参数的最后位置上 指定 pid 和 refresh-interval"); + } + break; + } else if ( i == args.length -1 ) { + option.setPid(v1); + } + if (args[i].equals("-sql")) { option.addPrintDataType(SQL); } else if (args[i].equals("-ds")) { option.addPrintDataType(DATA_SOURCE); } else if (args[i].equals("-act")) { option.addPrintDataType(ACTIVE_CONN); - } else if (args[i].equals("-s1")) { - option.setStyle(PrintStyle.HORIZONTAL); - } else if (args[i].equals("-s2")) { - option.setStyle(PrintStyle.VERTICAL); + } else if (args[i].equals("-detail")) { + option.setDetailPrint(true); } else if (args[i].equals("-id")) { try { int id = Integer.parseInt(args[i+1]); option.setId(id); + i++; } catch (NumberFormatException e) { - throw new OptionParseException("vmid argument is not a integer!"); + throw new OptionParseException("id参数必须是整数"); } } i++; } + if (option.getPrintDataType() == 0) { - throw new OptionParseException("please specify one or more arguments in {'-sql','-ds','-act'}."); + throw new OptionParseException("请在{'-sql','-ds','-act'}参数中选择一个或多个"); + } + if (option.getPid() == -1 ) { + throw new OptionParseException("请在参数中指定 pid"); } return option; } public static void printHelp() { - System.out.println("Usage: druidStat -help | -sql -ds -act -s1 -s2 -id vmid"); + System.out.println("Usage: druidStat -help | -sql -ds -act [-detail] [-id id] [refresh-interval]"); System.out.println(); - System.out.println("arguments: "); - System.out.println(" vmid the process id of jvm that running druid"); - System.out.println(" -sql print sql stat data"); - System.out.println(" -ds print datasource stat data"); - System.out.println(" -act print active connection stacktrace data"); - System.out.println(" -s1 print field name in first row"); - System.out.println(" -s2 print field name in first column"); - System.out.println(" -id only print the sql data matched with id, use this with -sql argument" ); - } + System.out.println("参数: "); + System.out.println(" -help 打印此帮助信息"); + System.out.println(" -sql 打印SQL统计数据"); + System.out.println(" -ds 打印DataSource统计数据"); + System.out.println(" -act 打印活动连接的堆栈信息"); + System.out.println(" -detail 打印统计数据的全部字段信息"); + System.out.println(" -id id 要打印的数据的具体id值" ); + System.out.println(" pid 使用druid连接池的jvm进程id"); + System.out.println(" refresh-interval 自动刷新时间间隔, 以秒为单位" ); + + System.out.println(); + System.out.println("说明: "); + System.out.println(" -sql,-ds,-act参数中要至少指定一种数据进行打印, 可以"); + System.out.println(" 组合使用, 比如 -sql -ds 一起的话就打印两种统计数据"); + System.out.println(" -id id可以跟 -sql 或-ds组合, 比如 -sql -id 5 或 -ds -id 1086752"); + System.out.println(" pid必需指定, refresh-interval可选, 如不指定,则打印数据后退出"); + System.out.println(" pid和refresh-interval参数必需放在命令行的最后, 否则解析会出错"); + + System.out.println(); + System.out.println("例子: "); + System.out.println(" 打印3983进程的sql 统计数据."); + System.out.println(" >druidStat -sql 3983"); + System.out.println(" 打印3983进程的ds统计数据."); + System.out.println(" >druidStat -ds 3983"); + System.out.println(" 打印3983进程的sql的id为10的详细统计数据."); + System.out.println(" >druidStat -sql -id 10 -detail 3983"); + System.out.println(" 打印3983进程的当前活动连接的堆栈信息"); + System.out.println(" >druidStat -act 3983"); + System.out.println(" 打印3983进程的ds,sql,和act信息"); + System.out.println(" >druidStat -ds -sql -act 3983"); + System.out.println(" 每隔5秒自动打印ds统计数据"); + System.out.println(" >druidStat -ds 3983 5"); + } public int getId() { return id; @@ -150,6 +185,18 @@ public class Option { this.id = id; } - + public void setDetailPrint(boolean detailPrint) { + this.detailPrint=detailPrint; + } + public boolean isDetailPrint() { + return this.detailPrint; + } + + public void setInterval(int interval) { + this.interval=interval; + } + public int getInterval() { + return this.interval; + } } diff --git a/src/main/java/com/alibaba/druid/support/console/TableFormatter.java b/src/main/java/com/alibaba/druid/support/console/TableFormatter.java index acbaef1d7d..725c4515bd 100644 --- a/src/main/java/com/alibaba/druid/support/console/TableFormatter.java +++ b/src/main/java/com/alibaba/druid/support/console/TableFormatter.java @@ -69,9 +69,13 @@ public class TableFormatter { } public static String padStr(String old, int length) { - if (old == null ) return ""; + if (old == null ) { + return ""; + } int vlen = displayLen(old); - if (vlen > length) return old; + if (vlen > length) { + return old; + } StringBuffer sb = new StringBuffer(old); for (int i=0; i< length -vlen ; i++) { sb.append(" "); diff --git a/src/main/java/com/alibaba/druid/support/console/TabledDataPrinter.java b/src/main/java/com/alibaba/druid/support/console/TabledDataPrinter.java index 8645e71a51..4ca6cd3faf 100644 --- a/src/main/java/com/alibaba/druid/support/console/TabledDataPrinter.java +++ b/src/main/java/com/alibaba/druid/support/console/TabledDataPrinter.java @@ -23,62 +23,42 @@ import com.alibaba.druid.sql.SQLUtils; public class TabledDataPrinter { - private static final int SQL_MAX_LEN = 32; - private static final int MAX_COL = 4; - - private static final String[] sqlRowTitle = new String[] { - "ID", "SQL", "ExecCount", "ExecTime", - "ExecMax","Txn", "Error","Update","FetchRow","Running","Concurrent", - "ExecHisto", "ExecRsHisto","FetchRowHisto","UpdateHisto" }; - - - private static final String[] sqlRowField = new String[] { - "ID", "SQL", "ExecuteCount", "TotalTime", "MaxTimespan", - "InTransactionCount", "ErrorCount", "EffectedRowCount", "FetchRowCount", - "RunningCount","ConcurrentMax","Histogram","ExecuteAndResultHoldTimeHistogram", - "FetchRowCountHistogram","EffectedRowCountHistogram" }; - - private static final String[] sqlColField = new String[] { - "ID", "DataSource", "SQL", "ExecuteCount", "ErrorCount", - "TotalTime", "LastTime", "MaxTimespan", "LastError", "EffectedRowCount", - "FetchRowCount", "MaxTimespanOccurTime", "BatchSizeMax", "BatchSizeTotal", "ConcurrentMax", - "RunningCount", "Name", "File", - "LastErrorMessage", "LastErrorClass", "LastErrorStackTrace", "LastErrorTime", - "DbType", "URL", "InTransactionCount", - "Histogram", "LastSlowParameters", "ResultSetHoldTime", "ExecuteAndResultSetHoldTime", "FetchRowCountHistogram", - "EffectedRowCountHistogram", "ExecuteAndResultHoldTimeHistogram", "EffectedRowCountMax", "FetchRowCountMax", "ClobOpenCount" }; + private static final int SQL_MAX_LEN = 32; + private static final int MAX_COL = 4; + private static final String[] sqlRowTitle = new String[] { "ID", "SQL", "ExecCount", "ExecTime", "ExecMax", "Txn", + "Error", "Update", "FetchRow", "Running", "Concurrent", "ExecRsHisto" }; - private static final String[] dsRowTitle = new String[] { - "Name", "DbType", - "PoolingCount", "PoolingPeak", "PoolingPeakTime", - "ActiveCount", "ActivePeak", "ActivePeakTime", - "ExecuteCount", "ErrorCount", "CommitCount", "RollbackCount" }; + private static final String[] sqlRowField = new String[] { "ID", "SQL", "ExecuteCount", "TotalTime", "MaxTimespan", + "InTransactionCount", "ErrorCount", "EffectedRowCount", "FetchRowCount", "RunningCount", "ConcurrentMax", + "ExecuteAndResultHoldTimeHistogram" }; - private static final String[] dsRowField = new String[] { - "Name", "DbType", - "PoolingCount", "PoolingPeak", "PoolingPeakTime", - "ActiveCount", "ActivePeak", "ActivePeakTime", - "ExecuteCount", "ErrorCount", "CommitCount", "RollbackCount" }; + private static final String[] sqlColField = new String[] { "ID", "DataSource", "SQL", "ExecuteCount", "ErrorCount", + "TotalTime", "LastTime", "MaxTimespan", "LastError", "EffectedRowCount", "FetchRowCount", + "MaxTimespanOccurTime", "BatchSizeMax", "BatchSizeTotal", "ConcurrentMax", "RunningCount", "Name", "File", + "LastErrorMessage", "LastErrorClass", "LastErrorStackTrace", "LastErrorTime", "DbType", "URL", + "InTransactionCount", "Histogram", "LastSlowParameters", "ResultSetHoldTime", + "ExecuteAndResultSetHoldTime", "FetchRowCountHistogram", "EffectedRowCountHistogram", + "ExecuteAndResultHoldTimeHistogram", "EffectedRowCountMax", "FetchRowCountMax", "ClobOpenCount" }; + private static final String[] dsRowTitle = new String[] { "Identity", "DbType", "PoolingCount", "PoolingPeak", + "PoolingPeakTime", "ActiveCount", "ActivePeak", "ActivePeakTime", "ExecuteCount", "ErrorCount" }; - private static final String[] dsColField = new String[] { - "Identity", "Name", "DbType", "DriverClassName", "URL", "UserName", "FilterClassNames", - "WaitThreadCount", "NotEmptyWaitCount", "NotEmptyWaitMillis", - "PoolingCount", "PoolingPeak", "PoolingPeakTime", - "ActiveCount", "ActivePeak", "ActivePeakTime", - "InitialSize", "MinIdle", "MaxActive", - "QueryTimeout", "TransactionQueryTimeout", "LoginTimeout", "ValidConnectionCheckerClassName", "ExceptionSorterClassName", - "TestOnBorrow", "TestOnReturn", "TestWhileIdle", - "DefaultAutoCommit", "DefaultReadOnly", "DefaultTransactionIsolation", - "LogicConnectCount", "LogicCloseCount", "LogicConnectErrorCount", - "PhysicalConnectCount", "PhysicalCloseCount", "PhysicalConnectErrorCount", - "ExecuteCount", "ErrorCount", "CommitCount", "RollbackCount", - "PSCacheAccessCount", "PSCacheHitCount", "PSCacheMissCount", - "StartTransactionCount", "TransactionHistogram", - "ConnectionHoldTimeHistogram", "RemoveAbandoned", "ClobOpenCount" }; + private static final String[] dsRowField = new String[] { "Identity", "DbType", "PoolingCount", "PoolingPeak", + "PoolingPeakTime", "ActiveCount", "ActivePeak", "ActivePeakTime", "ExecuteCount", "ErrorCount" }; - public static void printActiveConnStack(List> content,Option opt) { + private static final String[] dsColField = new String[] { "Identity", "Name", "DbType", "DriverClassName", "URL", + "UserName", "FilterClassNames", "WaitThreadCount", "NotEmptyWaitCount", "NotEmptyWaitMillis", + "PoolingCount", "PoolingPeak", "PoolingPeakTime", "ActiveCount", "ActivePeak", "ActivePeakTime", + "InitialSize", "MinIdle", "MaxActive", "QueryTimeout", "TransactionQueryTimeout", "LoginTimeout", + "ValidConnectionCheckerClassName", "ExceptionSorterClassName", "TestOnBorrow", "TestOnReturn", + "TestWhileIdle", "DefaultAutoCommit", "DefaultReadOnly", "DefaultTransactionIsolation", + "LogicConnectCount", "LogicCloseCount", "LogicConnectErrorCount", "PhysicalConnectCount", + "PhysicalCloseCount", "PhysicalConnectErrorCount", "ExecuteCount", "ErrorCount", "CommitCount", + "RollbackCount", "PSCacheAccessCount", "PSCacheHitCount", "PSCacheMissCount", "StartTransactionCount", + "TransactionHistogram", "ConnectionHoldTimeHistogram", "RemoveAbandoned", "ClobOpenCount" }; + + public static void printActiveConnStack(List> content, Option opt) { for (List stack : content) { for (String line : stack) { System.out.println(line); @@ -87,50 +67,91 @@ public class TabledDataPrinter { } } - public static void printDataSourceData(List> content,Option opt) { - if (opt.getStyle() == Option.PrintStyle.HORIZONTAL) { - System.out.println(getFormattedOutput(content, dsRowTitle, dsRowField)); - } else { + public static void printDataSourceData(List> content, Option opt) { + while (true) { + _printDataSourceData(content, opt); + if (opt.getInterval() == -1) { + break; + } + try { + Thread.sleep(opt.getInterval() * 1000); + } catch (Exception e) { + e.printStackTrace(); + break; + } + } + } + + public static void _printDataSourceData(List> content, Option opt) { + if (opt.getId() != -1) { + List> matchedContent = new ArrayList>(); + for (Map dsStat : content) { + Integer idStr = (Integer) dsStat.get("Identity"); + if (idStr.intValue() == opt.getId()) { + matchedContent.add(dsStat); + break; + } + } + content = matchedContent; + } + if (opt.isDetailPrint()) { System.out.println(getVerticalFormattedOutput(content, dsColField)); + } else { + System.out.println(getFormattedOutput(content, dsRowTitle, dsRowField)); } } public static void printSqlData(List> content, Option opt) { - if (opt.getId() != -1) { - List> matchedContent = new ArrayList>(); - for (Map sqlStat : content) { - Integer idStr = (Integer)sqlStat.get("ID"); - if (idStr.intValue() == opt.getId()) { - matchedContent.add(sqlStat); - String dbType = (String) sqlStat.get("DbType"); - String sql = (String) sqlStat.get("SQL"); - System.out.println(SQLUtils.format(sql, dbType)); - System.out.println("===============================\n"); - break; - } - } - content = matchedContent; - - - } - if (opt.getStyle() == Option.PrintStyle.HORIZONTAL) { - System.out.println(getFormattedOutput(content, sqlRowTitle, sqlRowField)); - } else { - System.out.println(getVerticalFormattedOutput(content, sqlColField)); + while (true) { + _printSqlData(content, opt); + if (opt.getInterval() == -1) { + break; + } + try { + Thread.sleep(opt.getInterval() * 1000); + } catch (Exception e) { + e.printStackTrace(); + break; + } } } - public static String getFormattedOutput(List> content, - String[] title , String[] rowField) { + public static void _printSqlData(List> content, Option opt) { + if (opt.getId() != -1) { + List> matchedContent = new ArrayList>(); + for (Map sqlStat : content) { + Integer idStr = (Integer) sqlStat.get("ID"); + if (idStr.intValue() == opt.getId()) { + matchedContent.add(sqlStat); + if (opt.isDetailPrint()) { + String dbType = (String) sqlStat.get("DbType"); + String sql = (String) sqlStat.get("SQL"); + System.out.println("Formatted SQL:"); + System.out.println(SQLUtils.format(sql, dbType)); + System.out.println(); + } + break; + } + } + content = matchedContent; + } + if (opt.isDetailPrint()) { + System.out.println(getVerticalFormattedOutput(content, sqlColField)); + } else { + System.out.println(getFormattedOutput(content, sqlRowTitle, sqlRowField)); + } + } + + public static String getFormattedOutput(List> content, String[] title, String[] rowField) { List printContents = new ArrayList(); printContents.add(title); - + for (Map sqlStat : content) { String[] row = new String[rowField.length]; for (int i = 0; i < rowField.length; ++i) { Object value = sqlStat.get(rowField[i]); - row[i] = handleAndConvert(value,rowField[i]); + row[i] = handleAndConvert(value, rowField[i]); } printContents.add(row); } @@ -138,19 +159,18 @@ public class TabledDataPrinter { return formattedStr; } - public static String getVerticalFormattedOutput(List> content, String[] titleFields) { List printContents = new ArrayList(); - int maxCol = content.size() > MAX_COL ? MAX_COL: content.size(); - + int maxCol = content.size() > MAX_COL ? MAX_COL : content.size(); + for (int i = 0; i < titleFields.length; ++i) { - String[] row = new String[maxCol+1]; + String[] row = new String[maxCol + 1]; row[0] = titleFields[i]; - for (int j=0; j< maxCol ; j++) { - Map sqlStat = content.get(j); + for (int j = 0; j < maxCol; j++) { + Map sqlStat = content.get(j); Object value = sqlStat.get(titleFields[i]); - row[j+1] = handleAndConvert(value, titleFields[i]); + row[j + 1] = handleAndConvert(value, titleFields[i]); } printContents.add(row); } @@ -159,13 +179,15 @@ public class TabledDataPrinter { } public static String handleAndConvert(Object value, String fieldName) { - if (value == null) value = ""; + if (value == null) { + value = ""; + } if (fieldName.equals("SQL")) { - String sql = (String)value; + String sql = (String) value; sql = sql.replace("\n", " "); sql = sql.replace("\t", " "); if (sql.length() > SQL_MAX_LEN) { - sql = sql.substring(0,SQL_MAX_LEN-3) + "..."; + sql = sql.substring(0, SQL_MAX_LEN - 3) + "..."; } value = sql; } diff --git a/src/main/java/com/alibaba/druid/support/http/StatViewServlet.java b/src/main/java/com/alibaba/druid/support/http/StatViewServlet.java index 61a105951c..2342ccb306 100644 --- a/src/main/java/com/alibaba/druid/support/http/StatViewServlet.java +++ b/src/main/java/com/alibaba/druid/support/http/StatViewServlet.java @@ -201,9 +201,9 @@ public class StatViewServlet extends HttpServlet { } if ("/submitLogin".equals(path)) { - String _username = request.getParameter(PARAM_NAME_USERNAME); - String _password = request.getParameter(PARAM_NAME_PASSWORD); - if (username.equals(_username) && password.equals(_password)) { + String usernameParam = request.getParameter(PARAM_NAME_USERNAME); + String passwordParam = request.getParameter(PARAM_NAME_PASSWORD); + if (username.equals(usernameParam) && password.equals(passwordParam)) { request.getSession().setAttribute(SESSION_USER_KEY, username); response.getWriter().print("success"); } else { diff --git a/src/main/java/com/alibaba/druid/support/http/WebStatFilter.java b/src/main/java/com/alibaba/druid/support/http/WebStatFilter.java index 8dc1c633d7..33d23f83e8 100644 --- a/src/main/java/com/alibaba/druid/support/http/WebStatFilter.java +++ b/src/main/java/com/alibaba/druid/support/http/WebStatFilter.java @@ -16,7 +16,6 @@ package com.alibaba.druid.support.http; import java.io.IOException; -import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -510,9 +509,5 @@ public class WebStatFilter implements Filter { public int getStatus() { return status; } - - public PrintWriter getWriter() throws IOException { - return super.getWriter(); - } } } diff --git a/src/main/java/com/alibaba/druid/support/http/stat/WebAppStat.java b/src/main/java/com/alibaba/druid/support/http/stat/WebAppStat.java index dd3e43d2cc..fef5588c3d 100644 --- a/src/main/java/com/alibaba/druid/support/http/stat/WebAppStat.java +++ b/src/main/java/com/alibaba/druid/support/http/stat/WebAppStat.java @@ -581,7 +581,7 @@ public class WebAppStat { } boolean isIE = userAgent.startsWith("MSIE", MOZILLA_COMPATIBLE_OFFSET); - int ie_prefix_index = 30; // "Mozilla/5.0 (compatible; MSIE ".length(); + int iePrefixIndex = 30; // "Mozilla/5.0 (compatible; MSIE ".length(); boolean isGoogleToolbar = false; @@ -592,7 +592,7 @@ public class WebAppStat { int tmp = userAgent.indexOf("IE "); if (tmp != -1) { isIE = true; - ie_prefix_index = tmp + 3; + iePrefixIndex = tmp + 3; } } } @@ -602,11 +602,11 @@ public class WebAppStat { browserIECount.incrementAndGet(); char v1 = ' ', v2 = ' '; - if (userAgent.length() > ie_prefix_index + 1) { - v1 = userAgent.charAt(ie_prefix_index); - v2 = userAgent.charAt(ie_prefix_index + 1); - } else if (userAgent.length() > ie_prefix_index) { - v1 = userAgent.charAt(ie_prefix_index); + if (userAgent.length() > iePrefixIndex + 1) { + v1 = userAgent.charAt(iePrefixIndex); + v2 = userAgent.charAt(iePrefixIndex + 1); + } else if (userAgent.length() > iePrefixIndex) { + v1 = userAgent.charAt(iePrefixIndex); } switch (v1) { @@ -706,7 +706,7 @@ public class WebAppStat { } else if (userAgent.indexOf("FreeBSD") != -1) { osFreeBSDCount.incrementAndGet(); isBSD = true; - } else if (isLinux == false && userAgent.indexOf("Linux") != -1) { + } else if ((!isLinux) && userAgent.indexOf("Linux") != -1) { osLinuxCount.incrementAndGet(); isLinux = true; } @@ -864,9 +864,6 @@ public class WebAppStat { osWindows2000Count.incrementAndGet(); } else if (userAgent.startsWith("Windows NT 5.0", 25)) { osWindows2000Count.incrementAndGet(); - - } else { - System.out.print(""); } } @@ -889,8 +886,6 @@ public class WebAppStat { osWindowsXPCount.incrementAndGet(); } else if (userAgent.startsWith("Windows XP", 34)) { osWindowsXPCount.incrementAndGet(); - } else { - System.out.print(""); } } diff --git a/src/main/java/com/alibaba/druid/support/http/util/IPAddress.java b/src/main/java/com/alibaba/druid/support/http/util/IPAddress.java index b0a3b34ce1..fb406bdec2 100644 --- a/src/main/java/com/alibaba/druid/support/http/util/IPAddress.java +++ b/src/main/java/com/alibaba/druid/support/http/util/IPAddress.java @@ -118,7 +118,7 @@ public class IPAddress implements Cloneable { * @exception InvalidIPAddressException Throws this exception when the specified string doesn't represent a valid IP * address. */ - public IPAddress(String ipAddressStr) { + public IPAddress(String ipAddressStr){ ipAddress = parseIPAddress(ipAddressStr); } @@ -212,7 +212,7 @@ public class IPAddress implements Cloneable { * @exception InvalidIPAddressException Throws this exception if the specified IP address is not compliant to the * decimal-dotted notation xxx.xxx.xxx.xxx. */ - protected int parseIPAddress(String ipAddressStr) { + final int parseIPAddress(String ipAddressStr) { int result = 0; if (ipAddressStr == null) { @@ -227,7 +227,7 @@ public class IPAddress implements Cloneable { for (int i = 0; i < 3; i++) { // get the position of the first dot - int index = tmp.indexOf("."); + int index = tmp.indexOf('.'); // if there is not a dot then the ip string representation is // not compliant to the decimal-dotted notation. @@ -262,50 +262,22 @@ public class IPAddress implements Cloneable { throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]"); } } catch (NoSuchElementException ex) { - throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]"); + throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]", ex); } catch (NumberFormatException ex) { - throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]"); + throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]", ex); } return result; } - // ------------------------------------------------------------------------- - /** - * Compare the specified IP address to the encapsulated one. - * - * @param another The IP address to be compared. - * @return Return true if the encapsulated IP address is the same as the specified one, otherwise - * return false. - */ + public int hashCode() { + return this.ipAddress; + } + public boolean equals(Object another) { if (another instanceof IPAddress) { return ipAddress == ((IPAddress) another).ipAddress; } return false; } - - // ------------------------------------------------------------------------- - /** - * Clone the encapsulated IP address. - * - * @return Return a new object representing the encapsulated IP address. - */ - public Object clone() { - return new IPAddress(ipAddress); - } - - public static void main(String[] args) { - - System.out.println(Integer.toBinaryString(255)); - - // try {//"192.168.1.1" - // IPAddress ip = new IPAddress(Integer.toBinaryString(3)); - // System.out.println(ip.getIPAddress()); - // System.out.println(ip.toString()); - // System.out.println(ip.parseIPAddress("192.168.4.4")); - // } catch (InvalidIPAddressException e) { - // e.printStackTrace(); - // } - } } diff --git a/src/main/java/com/alibaba/druid/support/http/util/IPRange.java b/src/main/java/com/alibaba/druid/support/http/util/IPRange.java index f7cd78f7f5..bfb0ad9889 100644 --- a/src/main/java/com/alibaba/druid/support/http/util/IPRange.java +++ b/src/main/java/com/alibaba/druid/support/http/util/IPRange.java @@ -193,12 +193,12 @@ public class IPRange { * @param range String representation of the IP range. * @exception InvalidIPRangeException Throws this exception if the specified range is not a valid IP network range. */ - protected void parseRange(String range) { + final void parseRange(String range) { if (range == null) { throw new IllegalArgumentException("Invalid IP range"); } - int index = range.indexOf("/"); + int index = range.indexOf('/'); String subnetStr = null; if (index == -1) { ipAddress = new IPAddress(range); @@ -226,7 +226,7 @@ public class IPRange { // create the corresponding subnet decimal extendedNetworkPrefix = computeNetworkPrefixFromMask(ipSubnetMask); if (extendedNetworkPrefix == -1) { - throw new IllegalArgumentException("Invalid IP range [" + range + "]"); + throw new IllegalArgumentException("Invalid IP range [" + range + "]", ex); } } } @@ -257,18 +257,19 @@ public class IPRange { } public static String toDecimalString(String inBinaryIpAddress) { - String decimalip = new String(); + StringBuilder decimalip = new StringBuilder(); String[] binary = new String[4]; for (int i = 0, c = 0; i < 32; i = i + 8, c++) { binary[c] = inBinaryIpAddress.substring(i, i + 8); int octet = Integer.parseInt(binary[c], 2); - decimalip = decimalip + Integer.toString(octet); + decimalip.append(octet); if (c < 3) { - decimalip = decimalip + "."; + + decimalip.append('.'); } } - return decimalip; + return decimalip.toString(); } // ------------------------------------------------------------------------- diff --git a/src/main/java/com/alibaba/druid/support/jconsole/DruidSQLPanel.java b/src/main/java/com/alibaba/druid/support/jconsole/DruidSQLPanel.java index 60e3063e26..81ad7703c3 100644 --- a/src/main/java/com/alibaba/druid/support/jconsole/DruidSQLPanel.java +++ b/src/main/java/com/alibaba/druid/support/jconsole/DruidSQLPanel.java @@ -91,7 +91,6 @@ public class DruidSQLPanel extends DruidPanel { add("FetchRowCountHistogram"); } }; - private RowHeaderTable header; public DruidSQLPanel() { super(); @@ -104,7 +103,7 @@ public class DruidSQLPanel extends DruidPanel { tableModel = new DruidTableModel(data,SHOW_LIST); table.setModel(tableModel); - header = new RowHeaderTable(table,20); + RowHeaderTable header = new RowHeaderTable(table,20); scrollPane.setRowHeaderView(header); } } diff --git a/src/main/java/com/alibaba/druid/support/json/JSONParser.java b/src/main/java/com/alibaba/druid/support/json/JSONParser.java index d8456370e5..9098b41994 100644 --- a/src/main/java/com/alibaba/druid/support/json/JSONParser.java +++ b/src/main/java/com/alibaba/druid/support/json/JSONParser.java @@ -153,7 +153,7 @@ public class JSONParser { throw new IllegalArgumentException("illegal token : " + token + ", expect " + token); } - void nextToken() { + final void nextToken() { if (index == Integer.MIN_VALUE) { token = Token.EOF; return; diff --git a/src/main/java/com/alibaba/druid/support/logging/Resources.java b/src/main/java/com/alibaba/druid/support/logging/Resources.java index 36e62baccb..8adc0fa605 100644 --- a/src/main/java/com/alibaba/druid/support/logging/Resources.java +++ b/src/main/java/com/alibaba/druid/support/logging/Resources.java @@ -28,7 +28,7 @@ import java.util.Properties; /** * A class to simplify access to resources through the classloader. */ -public class Resources extends Object { +public final class Resources extends Object { private static ClassLoader defaultClassLoader; @@ -79,9 +79,19 @@ public class Resources extends Object { */ public static URL getResourceURL(ClassLoader loader, String resource) throws IOException { URL url = null; - if (loader != null) url = loader.getResource(resource); - if (url == null) url = ClassLoader.getSystemResource(resource); - if (url == null) throw new IOException("Could not find resource " + resource); + + if (loader != null) { + url = loader.getResource(resource); + } + + if (url == null) { + url = ClassLoader.getSystemResource(resource); + } + + if (url == null) { + throw new IOException("Could not find resource " + resource); + } + return url; } @@ -106,9 +116,15 @@ public class Resources extends Object { */ public static InputStream getResourceAsStream(ClassLoader loader, String resource) throws IOException { InputStream in = null; - if (loader != null) in = loader.getResourceAsStream(resource); - if (in == null) in = ClassLoader.getSystemResourceAsStream(resource); - if (in == null) throw new IOException("Could not find resource " + resource); + if (loader != null) { + in = loader.getResourceAsStream(resource); + } + if (in == null) { + in = ClassLoader.getSystemResourceAsStream(resource); + } + if (in == null) { + throw new IOException("Could not find resource " + resource); + } return in; } diff --git a/src/main/java/com/alibaba/druid/support/spring/stat/BeanTypeAutoProxyCreator.java b/src/main/java/com/alibaba/druid/support/spring/stat/BeanTypeAutoProxyCreator.java index 42409d8536..968f7e701d 100644 --- a/src/main/java/com/alibaba/druid/support/spring/stat/BeanTypeAutoProxyCreator.java +++ b/src/main/java/com/alibaba/druid/support/spring/stat/BeanTypeAutoProxyCreator.java @@ -21,7 +21,6 @@ import java.util.List; import org.springframework.aop.TargetSource; import org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; @@ -52,7 +51,7 @@ public class BeanTypeAutoProxyCreator extends AbstractAutoProxyCreator implement this.targetBeanType = targetClass; } - public void setApplicationContext(ApplicationContext context) throws BeansException { + public void setApplicationContext(ApplicationContext context) { this.context = context; } diff --git a/src/main/java/com/alibaba/druid/support/spring/stat/SpringMethodInfo.java b/src/main/java/com/alibaba/druid/support/spring/stat/SpringMethodInfo.java index 2935e99268..39d4294564 100644 --- a/src/main/java/com/alibaba/druid/support/spring/stat/SpringMethodInfo.java +++ b/src/main/java/com/alibaba/druid/support/spring/stat/SpringMethodInfo.java @@ -82,13 +82,16 @@ public class SpringMethodInfo { public static String getMethodSignature(Method method) { StringBuffer sb = new StringBuffer(); - sb.append(method.getName() + "("); + sb.append(method.getName()); + sb.append('('); Class[] params = method.getParameterTypes(); for (int j = 0; j < params.length; j++) { sb.append(params[j].getName()); - if (j < (params.length - 1)) sb.append(","); + if (j < (params.length - 1)) { + sb.append(','); + } } - sb.append(")"); + sb.append(')'); return sb.toString(); } diff --git a/src/main/java/com/alibaba/druid/util/Base64.java b/src/main/java/com/alibaba/druid/util/Base64.java index 9da6277189..185c6d475f 100644 --- a/src/main/java/com/alibaba/druid/util/Base64.java +++ b/src/main/java/com/alibaba/druid/util/Base64.java @@ -124,7 +124,9 @@ public class Base64 { byte[] alphaToInt = (alternate ? altBase64ToInt : base64ToInt); int sLen = s.length(); int numGroups = sLen / 4; - if (4 * numGroups != sLen) throw new IllegalArgumentException("String length must be a multiple of four."); + if (4 * numGroups != sLen) { + throw new IllegalArgumentException("String length must be a multiple of four."); + } int missingBytesInLastGroup = 0; int numFullGroups = numGroups; if (sLen != 0) { @@ -132,7 +134,9 @@ public class Base64 { missingBytesInLastGroup++; numFullGroups--; } - if (s.charAt(sLen - 2) == '=') missingBytesInLastGroup++; + if (s.charAt(sLen - 2) == '=') { + missingBytesInLastGroup++; + } } byte[] result = new byte[3 * numGroups - missingBytesInLastGroup]; @@ -172,7 +176,9 @@ public class Base64 { */ private static int base64toInt(char c, byte[] alphaToInt) { int result = alphaToInt[c]; - if (result < 0) throw new IllegalArgumentException("Illegal character " + c); + if (result < 0) { + throw new IllegalArgumentException("Illegal character " + c); + } return result; } diff --git a/src/main/java/com/alibaba/druid/util/ConcurrentIdentityHashMap.java b/src/main/java/com/alibaba/druid/util/ConcurrentIdentityHashMap.java index b24d5e56d9..1b7b8ca1da 100644 --- a/src/main/java/com/alibaba/druid/util/ConcurrentIdentityHashMap.java +++ b/src/main/java/com/alibaba/druid/util/ConcurrentIdentityHashMap.java @@ -19,9 +19,7 @@ import java.util.AbstractCollection; import java.util.AbstractMap; import java.util.AbstractSet; import java.util.Collection; -import java.util.ConcurrentModificationException; import java.util.Enumeration; -import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; @@ -809,16 +807,6 @@ public class ConcurrentIdentityHashMap extends AbstractMap implement return found; } - /** - * Legacy method testing if some key maps into the specified value in this table. This method is identical in - * functionality to {@link #containsValue}, and exists solely to ensure full compatibility with class - * {@link Hashtable}, which supported this method prior to introduction of the Java Collections framework. - * - * @param value a value to search for - * @return true if and only if some key maps to the value argument in this table as determined by - * the equals method; false otherwise - * @throws NullPointerException if the specified value is null - */ public boolean contains(Object value) { return containsValue(value); } @@ -865,7 +853,7 @@ public class ConcurrentIdentityHashMap extends AbstractMap implement * @param m mappings to be stored in this map */ @Override - public void putAll(Map m) { + public final void putAll(Map m) { for (Map.Entry e : m.entrySet()) { put(e.getKey(), e.getValue()); } @@ -937,51 +925,18 @@ public class ConcurrentIdentityHashMap extends AbstractMap implement } } - /** - * Returns a {@link Set} view of the keys contained in this map. The set is backed by the map, so changes to the map - * are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding - * mapping from this map, via the Iterator.remove, Set.remove, removeAll, - * retainAll, and clear operations. It does not support the add or addAll - * operations. - *

- * The view's iterator is a "weakly consistent" iterator that will never throw - * {@link ConcurrentModificationException}, and guarantees to traverse elements as they existed upon construction of - * the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction. - */ @Override public Set keySet() { Set ks = keySet; return ks != null ? ks : (keySet = new KeySet()); } - /** - * Returns a {@link Collection} view of the values contained in this map. The collection is backed by the map, so - * changes to the map are reflected in the collection, and vice-versa. The collection supports element removal, - * which removes the corresponding mapping from this map, via the Iterator.remove, - * Collection.remove, removeAll, retainAll, and clear operations. It does not - * support the add or addAll operations. - *

- * The view's iterator is a "weakly consistent" iterator that will never throw - * {@link ConcurrentModificationException}, and guarantees to traverse elements as they existed upon construction of - * the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction. - */ @Override public Collection values() { Collection vs = values; return vs != null ? vs : (values = new Values()); } - /** - * Returns a {@link Set} view of the mappings contained in this map. The set is backed by the map, so changes to the - * map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding - * mapping from the map, via the Iterator.remove, Set.remove, removeAll, - * retainAll, and clear operations. It does not support the add or addAll - * operations. - *

- * The view's iterator is a "weakly consistent" iterator that will never throw - * {@link ConcurrentModificationException}, and guarantees to traverse elements as they existed upon construction of - * the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction. - */ @Override public Set> entrySet() { Set> es = entrySet; diff --git a/src/main/java/com/alibaba/druid/util/DruidDataSourceUtils.java b/src/main/java/com/alibaba/druid/util/DruidDataSourceUtils.java index 4720e6c1af..fd9a5cceba 100644 --- a/src/main/java/com/alibaba/druid/util/DruidDataSourceUtils.java +++ b/src/main/java/com/alibaba/druid/util/DruidDataSourceUtils.java @@ -44,6 +44,21 @@ public class DruidDataSourceUtils { } } + public static long getID(Object druidDatasource) { + if (druidDatasource.getClass() == DruidDataSource.class) { + return ((DruidDataSource) druidDatasource).getID(); + } + + try { + Method method = druidDatasource.getClass().getMethod("getID"); + Object obj = method.invoke(druidDatasource); + return (Long) obj; + } catch (Exception e) { + LOG.error("getID error", e); + return -1; + } + } + public static String getName(Object druidDatasource) { if (druidDatasource.getClass() == DruidDataSource.class) { return ((DruidDataSource) druidDatasource).getName(); diff --git a/src/main/java/com/alibaba/druid/util/HexBin.java b/src/main/java/com/alibaba/druid/util/HexBin.java index c508330eb0..809e4fb4d9 100644 --- a/src/main/java/com/alibaba/druid/util/HexBin.java +++ b/src/main/java/com/alibaba/druid/util/HexBin.java @@ -62,16 +62,19 @@ public final class HexBin { * @return return encoded string */ static public String encode(byte[] binaryData) { - if (binaryData == null) + if (binaryData == null) { return null; + } + int lengthData = binaryData.length; int lengthEncode = lengthData * 2; char[] encodedData = new char[lengthEncode]; int temp; for (int i = 0; i < lengthData; i++) { temp = binaryData[i]; - if (temp < 0) + if (temp < 0) { temp += 256; + } encodedData[i*2] = lookUpHexAlphabet[temp >> 4]; encodedData[i*2+1] = lookUpHexAlphabet[temp & 0xf]; } @@ -85,11 +88,14 @@ public final class HexBin { * @return return array of byte to encode */ static public byte[] decode(String encoded) { - if (encoded == null) + if (encoded == null) { return null; + } + int lengthData = encoded.length(); - if (lengthData % 2 != 0) + if (lengthData % 2 != 0) { return null; + } char[] binaryData = encoded.toCharArray(); int lengthDecode = lengthData / 2; @@ -99,12 +105,14 @@ public final class HexBin { for( int i = 0; i allItems = type1.keySet(); // Check all items in the type1 exist in type2 - if (!type2.keySet().containsAll(allItems)) return false; + if (!type2.keySet().containsAll(allItems)) { + return false; + } for (Iterator iter = allItems.iterator(); iter.hasNext();) { String item = (String) iter.next(); OpenType ot1 = type1.getType(item); OpenType ot2 = type2.getType(item); if (ot1 instanceof CompositeType) { - if (!(ot2 instanceof CompositeType)) return false; - if (!isTypeMatched((CompositeType) ot1, (CompositeType) ot2)) return false; + if (!(ot2 instanceof CompositeType)) { + return false; + } + if (!isTypeMatched((CompositeType) ot1, (CompositeType) ot2)) { + return false; + } } else if (ot1 instanceof TabularType) { - if (!(ot2 instanceof TabularType)) return false; - if (!isTypeMatched((TabularType) ot1, (TabularType) ot2)) return false; + if (!(ot2 instanceof TabularType)) { + return false; + } + if (!isTypeMatched((TabularType) ot1, (TabularType) ot2)) { + return false; + } } else if (!ot1.equals(ot2)) { return false; } @@ -155,13 +177,17 @@ public abstract class LazyCompositeData implements CompositeData, Serializable { } protected static boolean isTypeMatched(TabularType type1, TabularType type2) { - if (type1 == type2) return true; + if (type1 == type2) { + return true; + } List list1 = type1.getIndexNames(); List list2 = type2.getIndexNames(); // check if the list of index names are the same - if (!list1.equals(list2)) return false; + if (!list1.equals(list2)) { + return false; + } return isTypeMatched(type1.getRowType(), type2.getRowType()); } diff --git a/src/main/java/com/alibaba/druid/util/MapComparator.java b/src/main/java/com/alibaba/druid/util/MapComparator.java index 878cf8c67c..5438e72bfa 100644 --- a/src/main/java/com/alibaba/druid/util/MapComparator.java +++ b/src/main/java/com/alibaba/druid/util/MapComparator.java @@ -50,7 +50,9 @@ public class MapComparator implements Compar public int compare(Map o1, Map o2) { int result = compare_0(o1, o2); - if (isDesc) result = -result; + if (isDesc) { + result = -result; + } return result; } @@ -60,8 +62,10 @@ public class MapComparator implements Compar String keyStr = (String) key; if (keyStr.matches(".+\\[[0-9]+\\]")) { - Object value = map.get(keyStr.substring(0, keyStr.indexOf("["))); - if (value == null) return null; + Object value = map.get(keyStr.substring(0, keyStr.indexOf('['))); + if (value == null) { + return null; + } Integer index = StringUtils.subStringToInteger(keyStr, "[", "]"); if (value.getClass().isArray() && Array.getLength(value) >= index) { @@ -78,15 +82,27 @@ public class MapComparator implements Compar Object v1 = getValueByKey(o1, orderByKey); Object v2 = getValueByKey(o2, orderByKey); - if (v1 == null && v2 == null) return 0; - if (v1 == null) return -1; - if (v2 == null) return 1; + if (v1 == null && v2 == null) { + return 0; + } + if (v1 == null) { + return -1; + } + if (v2 == null) { + return 1; + } - if (v1 instanceof Number) return compare((Number) v1, (Number) v2); + if (v1 instanceof Number) { + return compare((Number) v1, (Number) v2); + } - if (v1 instanceof String) return compare((String) v1, (String) v2); + if (v1 instanceof String) { + return compare((String) v1, (String) v2); + } - if (v1 instanceof Date) return compare((Date) v1, (Date) v2); + if (v1 instanceof Date) { + return compare((Date) v1, (Date) v2); + } return 0; } diff --git a/src/main/java/com/alibaba/druid/util/StringUtils.java b/src/main/java/com/alibaba/druid/util/StringUtils.java index 7b8e7dabd2..f3750190e1 100644 --- a/src/main/java/com/alibaba/druid/util/StringUtils.java +++ b/src/main/java/com/alibaba/druid/util/StringUtils.java @@ -15,9 +15,6 @@ */ package com.alibaba.druid.util; -import java.util.LinkedHashMap; -import java.util.Map; - import com.alibaba.druid.support.logging.Log; import com.alibaba.druid.support.logging.LogFactory; @@ -64,9 +61,14 @@ public class StringUtils { * @return */ public static Integer stringToInteger(String in) { - if (in == null) return null; + if (in == null) { + return null; + } in = in.trim(); - if (in.length() == 0) return null; + if (in.length() == 0) { + return null; + } + try { return Integer.parseInt(in); } catch (NumberFormatException e) { @@ -75,26 +77,6 @@ public class StringUtils { } } - public static Map getParameters(String url) { - if (url == null || (url = url.trim()).length() == 0) return null; - - String parametersStr = subString(url, "?", null); - if (parametersStr == null || parametersStr.length() == 0) return null; - - String[] parametersArray = parametersStr.split("&"); - Map parameters = new LinkedHashMap(); - - for (String parameterStr : parametersArray) { - int index = parameterStr.indexOf("="); - if (index <= 0) continue; - - String name = parameterStr.substring(0, index); - String value = parameterStr.substring(index + 1); - parameters.put(name, value); - } - return parameters; - } - public static boolean equals(String a, String b) { if (a == null) { return b == null; diff --git a/src/main/java/com/alibaba/druid/util/ThreadLocalRandom.java b/src/main/java/com/alibaba/druid/util/ThreadLocalRandom.java index 5aa1b4ccbd..1859ed23c0 100644 --- a/src/main/java/com/alibaba/druid/util/ThreadLocalRandom.java +++ b/src/main/java/com/alibaba/druid/util/ThreadLocalRandom.java @@ -15,81 +15,71 @@ */ package com.alibaba.druid.util; - - import java.util.Random; /** - * A random number generator isolated to the current thread. Like the - * global {@link java.util.Random} generator used by the {@link - * java.lang.Math} class, a {@code ThreadLocalRandom} is initialized - * with an internally generated seed that may not otherwise be - * modified. When applicable, use of {@code ThreadLocalRandom} rather - * than shared {@code Random} objects in concurrent programs will - * typically encounter much less overhead and contention. Use of - * {@code ThreadLocalRandom} is particularly appropriate when multiple - * tasks (for example, each a {@link ForkJoinTask}) use random numbers - * in parallel in thread pools. - * - *

Usages of this class should typically be of the form: - * {@code ThreadLocalRandom.current().nextX(...)} (where - * {@code X} is {@code Int}, {@code Long}, etc). - * When all usages are of this form, it is never possible to - * accidently share a {@code ThreadLocalRandom} across multiple threads. - * - *

This class also provides additional commonly used bounded random - * generation methods. - * + * A random number generator isolated to the current thread. Like the global {@link java.util.Random} generator used by + * the {@link java.lang.Math} class, a {@code ThreadLocalRandom} is initialized with an internally generated seed that + * may not otherwise be modified. When applicable, use of {@code ThreadLocalRandom} rather than shared {@code Random} + * objects in concurrent programs will typically encounter much less overhead and contention. Use of + * {@code ThreadLocalRandom} is particularly appropriate when multiple tasks (for example, each a {@link ForkJoinTask}) + * use random numbers in parallel in thread pools. + *

+ * Usages of this class should typically be of the form: {@code ThreadLocalRandom.current().nextX(...)} (where {@code X} + * is {@code Int}, {@code Long}, etc). When all usages are of this form, it is never possible to accidently share a + * {@code ThreadLocalRandom} across multiple threads. + *

+ * This class also provides additional commonly used bounded random generation methods. + * * @since 1.7 * @author Doug Lea */ public class ThreadLocalRandom extends Random { + // same constants as Random, but must be redeclared because private - private static final long multiplier = 0x5DEECE66DL; - private static final long addend = 0xBL; - private static final long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long addend = 0xBL; + private static final long mask = (1L << 48) - 1; /** * The random seed. We can't use super.seed. */ - private long rnd; + private long rnd; /** - * Initialization flag to permit calls to setSeed to succeed only - * while executing the Random constructor. We can't allow others - * since it would cause setting seed in one part of a program to - * unintentionally impact other usages by the thread. + * Initialization flag to permit calls to setSeed to succeed only while executing the Random constructor. We can't + * allow others since it would cause setting seed in one part of a program to unintentionally impact other usages by + * the thread. */ - boolean initialized; + boolean initialized; // Padding to help avoid memory contention among seed updates in // different TLRs in the common case that they are located near // each other. @SuppressWarnings("unused") - private long pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7; + private long pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7; /** * The actual ThreadLocal */ - private static final ThreadLocal localRandom = - new ThreadLocal() { - protected ThreadLocalRandom initialValue() { - return new ThreadLocalRandom(); - } - }; + private static final ThreadLocal localRandom = new ThreadLocal() { + protected ThreadLocalRandom initialValue() { + return new ThreadLocalRandom(); + } + }; /** * Constructor called only by localRandom.initialValue. */ - ThreadLocalRandom() { + ThreadLocalRandom(){ super(); initialized = true; } /** * Returns the current thread's {@code ThreadLocalRandom}. - * + * * @return the current thread's {@code ThreadLocalRandom} */ public static ThreadLocalRandom current() { @@ -97,50 +87,49 @@ public class ThreadLocalRandom extends Random { } /** - * Throws {@code UnsupportedOperationException}. Setting seeds in - * this generator is not supported. - * + * Throws {@code UnsupportedOperationException}. Setting seeds in this generator is not supported. + * * @throws UnsupportedOperationException always */ public void setSeed(long seed) { - if (initialized) + if (initialized) { throw new UnsupportedOperationException(); + } rnd = (seed ^ multiplier) & mask; } protected int next(int bits) { rnd = (rnd * multiplier + addend) & mask; - return (int) (rnd >>> (48-bits)); + return (int) (rnd >>> (48 - bits)); } /** - * Returns a pseudorandom, uniformly distributed value between the - * given least value (inclusive) and bound (exclusive). - * + * Returns a pseudorandom, uniformly distributed value between the given least value (inclusive) and bound + * (exclusive). + * * @param least the least value returned * @param bound the upper bound (exclusive) - * @throws IllegalArgumentException if least greater than or equal - * to bound + * @throws IllegalArgumentException if least greater than or equal to bound * @return the next value */ public int nextInt(int least, int bound) { - if (least >= bound) + if (least >= bound) { throw new IllegalArgumentException(); + } return nextInt(bound - least) + least; } /** - * Returns a pseudorandom, uniformly distributed value - * between 0 (inclusive) and the specified value (exclusive). - * - * @param n the bound on the random number to be returned. Must be - * positive. + * Returns a pseudorandom, uniformly distributed value between 0 (inclusive) and the specified value (exclusive). + * + * @param n the bound on the random number to be returned. Must be positive. * @return the next value * @throws IllegalArgumentException if n is not positive */ public long nextLong(long n) { - if (n <= 0) + if (n <= 0) { throw new IllegalArgumentException("n must be positive"); + } // Divide n by two until small enough for nextInt. On each // iteration (at most 31 of them but usually much less), // randomly choose both whether to include high bit in result @@ -151,57 +140,58 @@ public class ThreadLocalRandom extends Random { int bits = next(2); long half = n >>> 1; long nextn = ((bits & 2) == 0) ? half : n - half; - if ((bits & 1) == 0) + if ((bits & 1) == 0) { offset += n - nextn; + } n = nextn; } return offset + nextInt((int) n); } /** - * Returns a pseudorandom, uniformly distributed value between the - * given least value (inclusive) and bound (exclusive). - * + * Returns a pseudorandom, uniformly distributed value between the given least value (inclusive) and bound + * (exclusive). + * * @param least the least value returned * @param bound the upper bound (exclusive) * @return the next value - * @throws IllegalArgumentException if least greater than or equal - * to bound + * @throws IllegalArgumentException if least greater than or equal to bound */ public long nextLong(long least, long bound) { - if (least >= bound) + if (least >= bound) { throw new IllegalArgumentException(); + } return nextLong(bound - least) + least; } /** - * Returns a pseudorandom, uniformly distributed {@code double} value - * between 0 (inclusive) and the specified value (exclusive). - * - * @param n the bound on the random number to be returned. Must be - * positive. + * Returns a pseudorandom, uniformly distributed {@code double} value between 0 (inclusive) and the specified value + * (exclusive). + * + * @param n the bound on the random number to be returned. Must be positive. * @return the next value * @throws IllegalArgumentException if n is not positive */ public double nextDouble(double n) { - if (n <= 0) + if (n <= 0) { throw new IllegalArgumentException("n must be positive"); + } return nextDouble() * n; } /** - * Returns a pseudorandom, uniformly distributed value between the - * given least value (inclusive) and bound (exclusive). - * + * Returns a pseudorandom, uniformly distributed value between the given least value (inclusive) and bound + * (exclusive). + * * @param least the least value returned * @param bound the upper bound (exclusive) * @return the next value - * @throws IllegalArgumentException if least greater than or equal - * to bound + * @throws IllegalArgumentException if least greater than or equal to bound */ public double nextDouble(double least, double bound) { - if (least >= bound) + if (least >= bound) { throw new IllegalArgumentException(); + } return nextDouble() * (bound - least) + least; } diff --git a/src/main/java/com/alibaba/druid/util/jdbc/StatementBase.java b/src/main/java/com/alibaba/druid/util/jdbc/StatementBase.java index a7ae44d0ca..9f4d7d36e0 100644 --- a/src/main/java/com/alibaba/druid/util/jdbc/StatementBase.java +++ b/src/main/java/com/alibaba/druid/util/jdbc/StatementBase.java @@ -58,7 +58,7 @@ public abstract class StatementBase implements Statement { this.connection = connection; } - protected void checkOpen() throws SQLException, MockConnectionClosedException { + protected void checkOpen() throws SQLException { if (closed) { throw new SQLException(); } diff --git a/src/main/java/com/alibaba/druid/wall/WallConfig.java b/src/main/java/com/alibaba/druid/wall/WallConfig.java index 6810ccdf7f..231c2481b9 100644 --- a/src/main/java/com/alibaba/druid/wall/WallConfig.java +++ b/src/main/java/com/alibaba/druid/wall/WallConfig.java @@ -90,7 +90,7 @@ public class WallConfig implements WallConfigMBean { this.dir = dir; } - public void init() { + public final void init() { loadConfig(dir); } diff --git a/src/main/java/com/alibaba/druid/wall/spi/MySqlWallVisitor.java b/src/main/java/com/alibaba/druid/wall/spi/MySqlWallVisitor.java index aa2328d85e..e66e515b4c 100644 --- a/src/main/java/com/alibaba/druid/wall/spi/MySqlWallVisitor.java +++ b/src/main/java/com/alibaba/druid/wall/spi/MySqlWallVisitor.java @@ -126,7 +126,7 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi WallVisitorUtils.checkDelete(this, x); return true; } - + @Override public boolean visit(MySqlUpdateStatement x) { return visit((SQLUpdateStatement) x); @@ -241,21 +241,22 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi return; } + boolean allow = false; if (x instanceof SQLInsertStatement) { - + allow = true; } else if (x instanceof SQLSelectStatement) { - + allow = true; } else if (x instanceof SQLDeleteStatement) { - + allow = true; } else if (x instanceof SQLUpdateStatement) { - + allow = true; } else if (x instanceof SQLCallStatement) { - + allow = true; } else if (x instanceof SQLTruncateStatement) { - if (!config.isTruncateAllow()) { - violations.add(new IllegalSQLObjectViolation(toSQL(x))); - } - } else { + allow = config.isTruncateAllow(); + } + + if (!allow) { violations.add(new IllegalSQLObjectViolation(toSQL(x))); } } diff --git a/src/main/java/com/alibaba/druid/wall/spi/OracleWallVisitor.java b/src/main/java/com/alibaba/druid/wall/spi/OracleWallVisitor.java index 471f091be4..1bd22f2bdb 100644 --- a/src/main/java/com/alibaba/druid/wall/spi/OracleWallVisitor.java +++ b/src/main/java/com/alibaba/druid/wall/spi/OracleWallVisitor.java @@ -174,21 +174,26 @@ public class OracleWallVisitor extends OracleASTVisitorAdapter implements WallVi return; } + boolean allow = false; if (x instanceof SQLInsertStatement) { - + allow = true; } else if (x instanceof SQLSelectStatement) { - + allow = true; } else if (x instanceof SQLDeleteStatement) { - + allow = true; } else if (x instanceof SQLUpdateStatement) { + allow = true; } else if (x instanceof OracleMultiInsertStatement) { + allow = true; } else if (x instanceof OracleMergeStatement) { + allow = true; } else if (x instanceof SQLCallStatement) { + allow = true; } else if (x instanceof SQLTruncateStatement) { - if (!config.isTruncateAllow()) { - violations.add(new IllegalSQLObjectViolation(toSQL(x))); - } - } else { + allow = config.isTruncateAllow(); + } + + if (!allow) { violations.add(new IllegalSQLObjectViolation(toSQL(x))); } } diff --git a/src/main/java/com/alibaba/druid/wall/spi/SQLServerWallVisitor.java b/src/main/java/com/alibaba/druid/wall/spi/SQLServerWallVisitor.java index 001a334f80..179b5bc25f 100644 --- a/src/main/java/com/alibaba/druid/wall/spi/SQLServerWallVisitor.java +++ b/src/main/java/com/alibaba/druid/wall/spi/SQLServerWallVisitor.java @@ -53,7 +53,7 @@ public class SQLServerWallVisitor extends SQLServerASTVisitorAdapter implements private final WallProvider provider; private final List violations = new ArrayList(); - public SQLServerWallVisitor(WallProvider provider) { + public SQLServerWallVisitor(WallProvider provider){ this.config = provider.getConfig(); this.provider = provider; } @@ -156,20 +156,22 @@ public class SQLServerWallVisitor extends SQLServerASTVisitorAdapter implements return; } + boolean allow = false; if (x instanceof SQLInsertStatement) { - + allow = true; } else if (x instanceof SQLSelectStatement) { - + allow = true; } else if (x instanceof SQLDeleteStatement) { - + allow = true; } else if (x instanceof SQLUpdateStatement) { + allow = true; } else if (x instanceof SQLCallStatement) { - + allow = true; } else if (x instanceof SQLTruncateStatement) { - if (!config.isTruncateAllow()) { - violations.add(new IllegalSQLObjectViolation(toSQL(x))); - } - } else { + allow = config.isTruncateAllow(); + } + + if (!allow) { violations.add(new IllegalSQLObjectViolation(toSQL(x))); } } diff --git a/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java b/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java index fc25109eef..7236ac488f 100644 --- a/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java +++ b/src/main/java/com/alibaba/druid/wall/spi/WallVisitorUtils.java @@ -414,7 +414,7 @@ public class WallVisitorUtils { if (x instanceof SQLNotExpr) { Object result = getValue(((SQLNotExpr) x).getExpr()); - if (result != null && result instanceof Boolean) { + if (result instanceof Boolean) { return !((Boolean) result).booleanValue(); } } diff --git a/src/main/resources/support/http/resources/datasource.html b/src/main/resources/support/http/resources/datasource.html index eaa499d7bb..28f7b2908e 100644 --- a/src/main/resources/support/http/resources/datasource.html +++ b/src/main/resources/support/http/resources/datasource.html @@ -30,7 +30,9 @@ "NotEmptyWaitMillis", "WaitThreadCount", "StartTransactionCount", "TransactionHistogram", "PoolingCount", "PoolingPeak", "PoolingPeakTime", "ActiveCount", "ActivePeak", "ActivePeakTime", "LogicConnectCount", "LogicCloseCount", "LogicConnectErrorCount", "PhysicalConnectCount", "PhysicalCloseCount", "PhysicalConnectErrorCount", "ExecuteCount", "ErrorCount", "CommitCount", - "RollbackCount", "PSCacheAccessCount", "PSCacheHitCount", "PSCacheMissCount", "ConnectionHoldTimeHistogram"] + "RollbackCount", "PSCacheAccessCount", "PSCacheHitCount", "PSCacheMissCount", "ConnectionHoldTimeHistogram", + "ClobOpenCount", "BlobOpenCount" + ] var descs = ["Specify the username used when creating a new connection.", "The JDBC driver connection URL", "database type", "The fully qualifed name of the JDBC driver class", "All the fully qualifed name of the filter classes", " Test or not when borrow a connection", "Test or not when return a connection", @@ -42,7 +44,9 @@ "The usefull connection peak time", "The current active connection count", "The current active connection peak count", "The active connection peak time", "Total connect times from datasource", "Total close connect times from datasource", "Total connect error times", "Create physical connnection count", "Close physical connnection count", "Total physical connect error times", "", "", "", - "", "PerpareStatement access count", "PerpareStatement hit count", "PerpareStatement miss count", "The histogram values of connection hold time, [0-1 ms, 1-10 ms, 10-100 ms, 100ms-1s, 1-10 s, 10-100 s, 100-1000 s, >1000 s]"] + "", "PerpareStatement access count", "PerpareStatement hit count", "PerpareStatement miss count", "The histogram values of connection hold time, [0-1 ms, 1-10 ms, 10-100 ms, 100ms-1s, 1-10 s, 10-100 s, 100-1000 s, >1000 s]", + "", "" + ] return { init : function() { druid.common.buildHead(1); @@ -114,6 +118,8 @@ html += 'PollingConnection InfoViewInfo for polling connection. [View JSON API]' + html += 'SQL ListViewInfo for SQL. [View JSON API]' html += ''; return html; diff --git a/src/main/resources/support/http/resources/sql-detail.html b/src/main/resources/support/http/resources/sql-detail.html index 8cfaf38f1d..b3ad5478b2 100644 --- a/src/main/resources/support/http/resources/sql-detail.html +++ b/src/main/resources/support/http/resources/sql-detail.html @@ -85,7 +85,7 @@
-

Batch View:

+

Other View:

@@ -95,6 +95,30 @@ + + + + + + + + + + + + + + + + + + + + + + + +
BatchSizeMaxBatchSizeTotal
BlobOpenCount
ClobOpenCount
ReaderOpenCount
InputStreamOpenCount
ReadStringLength
ReadBytesLength
Close @@ -141,6 +165,12 @@ $("#BatchSizeMax").text(sqlInfo.BatchSizeMax) $("#BatchSizeTotal").text(sqlInfo.BatchSizeTotal) + $("#BlobOpenCount").text(sqlInfo.BlobOpenCount) + $("#ClobOpenCount").text(sqlInfo.ClobOpenCount) + $("#InputStreamOpenCount").text(sqlInfo.InputStreamOpenCount) + $("#ReaderOpenCount").text(sqlInfo.ReaderOpenCount) + $("#ReadStringLength").text(sqlInfo.ReadStringLength) + $("#ReadBytesLength").text(sqlInfo.ReadBytesLength) }, dataType: "json" }); diff --git a/src/main/resources/support/http/resources/sql.html b/src/main/resources/support/http/resources/sql.html index 939a33cf18..2d7055c825 100644 --- a/src/main/resources/support/http/resources/sql.html +++ b/src/main/resources/support/http/resources/sql.html @@ -75,14 +75,15 @@