2 * $Id: LoggingStatement.java 413 2011-07-28 23:05:11Z dobashi $
\r
4 * (c)2004 Lavans Networks Inc. All Rights Reserved.
\r
6 package com.lavans.luz2.sql.logging;
\r
8 import java.sql.Connection;
\r
9 import java.sql.ResultSet;
\r
10 import java.sql.SQLException;
\r
11 import java.sql.SQLWarning;
\r
12 import java.sql.Statement;
\r
14 import org.apache.commons.logging.Log;
\r
15 import org.apache.commons.logging.LogFactory;
\r
17 import com.lavans.luz2.util.MethodUtil;
\r
23 public class LoggingStatement implements Statement {
\r
25 private Statement st=null;
\r
27 /** 自クラス名。使うたびにgetName()すると遅くなるのでここで定義しておく。 */
\r
28 private static final String CLASSNAME=LoggingStatement.class.getName();
\r
31 private static Log logger = LogFactory.getLog(LoggingStatement.class);
\r
34 // public void setLogger(Log value){
\r
42 public LoggingStatement(Statement st){
\r
48 * BindStatementを"implements PreparedStatement"ではなく
\r
49 * "extends LoggerPreparedStatement"にするための回避策として、
\r
50 * 引数無しのコンストラクタをprotectedで用意する。
\r
52 // protected LoggingStatement(){
\r
56 * @see java.sql.Statement#executeQuery(java.lang.String)
\r
58 public ResultSet executeQuery(String sql) throws SQLException {
\r
59 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
60 return st.executeQuery(sql);
\r
64 * @see java.sql.Statement#executeUpdate(java.lang.String)
\r
66 public int executeUpdate(String sql) throws SQLException {
\r
67 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
68 return st.executeUpdate(sql);
\r
73 * @see java.sql.Statement#executeUpdate(java.lang.String, int)
\r
75 public int executeUpdate(String sql, int autoGeneratedKeys)
\r
76 throws SQLException {
\r
77 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
78 return st.executeUpdate(sql,autoGeneratedKeys);
\r
82 * @see java.sql.Statement#executeUpdate(java.lang.String, int[])
\r
84 public int executeUpdate(String sql, int[] columnIndexes)
\r
85 throws SQLException {
\r
86 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
87 return st.executeUpdate(sql,columnIndexes);
\r
91 * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])
\r
93 public int executeUpdate(String sql, String[] columnNames)
\r
94 throws SQLException {
\r
95 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
96 return st.executeUpdate(sql,columnNames);
\r
100 * @see java.sql.Statement#execute(java.lang.String, int)
\r
102 public boolean execute(String sql, int autoGeneratedKeys)
\r
103 throws SQLException {
\r
104 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
105 return st.execute(sql,autoGeneratedKeys);
\r
109 * @see java.sql.Statement#execute(java.lang.String)
\r
111 public boolean execute(String sql) throws SQLException {
\r
112 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
113 return st.execute(sql);
\r
117 * @see java.sql.Statement#execute(java.lang.String, int[])
\r
119 public boolean execute(String sql, int[] columnIndexes)
\r
120 throws SQLException {
\r
121 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
122 return st.execute(sql,columnIndexes);
\r
126 * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])
\r
128 public boolean execute(String sql, String[] columnNames)
\r
129 throws SQLException {
\r
130 logger.info(MethodUtil.getMethodName(CLASSNAME) +"\n"+sql);
\r
131 return st.execute(sql,columnNames);
\r
139 * @see java.sql.Statement#getFetchDirection()
\r
141 public int getFetchDirection() throws SQLException {
\r
142 return st.getFetchDirection();
\r
146 * @see java.sql.Statement#getFetchSize()
\r
148 public int getFetchSize() throws SQLException {
\r
149 return st.getFetchSize();
\r
153 * @see java.sql.Statement#getMaxFieldSize()
\r
155 public int getMaxFieldSize() throws SQLException {
\r
156 return st.getMaxFieldSize();
\r
160 * @see java.sql.Statement#getMaxRows()
\r
162 public int getMaxRows() throws SQLException {
\r
163 return st.getMaxRows();
\r
167 * @see java.sql.Statement#getQueryTimeout()
\r
169 public int getQueryTimeout() throws SQLException {
\r
170 return st.getQueryTimeout();
\r
174 * @see java.sql.Statement#getResultSetConcurrency()
\r
176 public int getResultSetConcurrency() throws SQLException {
\r
177 return st.getResultSetConcurrency();
\r
181 * @see java.sql.Statement#getResultSetHoldability()
\r
183 public int getResultSetHoldability() throws SQLException {
\r
184 return st.getResultSetHoldability();
\r
188 * @see java.sql.Statement#getResultSetType()
\r
190 public int getResultSetType() throws SQLException {
\r
191 return st.getResultSetType();
\r
195 * @see java.sql.Statement#getUpdateCount()
\r
197 public int getUpdateCount() throws SQLException {
\r
198 return st.getUpdateCount();
\r
202 * @see java.sql.Statement#cancel()
\r
204 public void cancel() throws SQLException {
\r
209 * @see java.sql.Statement#clearBatch()
\r
211 public void clearBatch() throws SQLException {
\r
216 * @see java.sql.Statement#clearWarnings()
\r
218 public void clearWarnings() throws SQLException {
\r
219 st.clearWarnings();
\r
223 * @see java.sql.Statement#close()
\r
225 public void close() throws SQLException {
\r
230 * @see java.sql.Statement#getMoreResults()
\r
232 public boolean getMoreResults() throws SQLException {
\r
233 return st.getMoreResults();
\r
237 * @see java.sql.Statement#executeBatch()
\r
239 public int[] executeBatch() throws SQLException {
\r
240 return st.executeBatch();
\r
244 * @see java.sql.Statement#setFetchDirection(int)
\r
246 public void setFetchDirection(int direction) throws SQLException {
\r
247 st.setFetchDirection(direction);
\r
251 * @see java.sql.Statement#setFetchSize(int)
\r
253 public void setFetchSize(int rows) throws SQLException {
\r
254 st.setFetchSize(rows);
\r
258 * @see java.sql.Statement#setMaxFieldSize(int)
\r
260 public void setMaxFieldSize(int max) throws SQLException {
\r
261 st.setMaxFieldSize(max);
\r
265 * @see java.sql.Statement#setMaxRows(int)
\r
267 public void setMaxRows(int max) throws SQLException {
\r
268 st.setMaxRows(max);
\r
272 * @see java.sql.Statement#setQueryTimeout(int)
\r
274 public void setQueryTimeout(int seconds) throws SQLException {
\r
275 st.setQueryTimeout(seconds);
\r
279 * @see java.sql.Statement#getMoreResults(int)
\r
281 public boolean getMoreResults(int current) throws SQLException {
\r
282 return st.getMoreResults(current);
\r
286 * @see java.sql.Statement#setEscapeProcessing(boolean)
\r
288 public void setEscapeProcessing(boolean enable) throws SQLException {
\r
289 st.setEscapeProcessing(enable);
\r
294 * @see java.sql.Statement#addBatch(java.lang.String)
\r
296 public void addBatch(String sql) throws SQLException {
\r
301 * @see java.sql.Statement#setCursorName(java.lang.String)
\r
303 public void setCursorName(String name) throws SQLException {
\r
304 st.setCursorName(name);
\r
309 * @see java.sql.Statement#getConnection()
\r
311 public Connection getConnection() throws SQLException {
\r
312 return st.getConnection();
\r
316 * @see java.sql.Statement#getGeneratedKeys()
\r
318 public ResultSet getGeneratedKeys() throws SQLException {
\r
319 return st.getGeneratedKeys();
\r
323 * @see java.sql.Statement#getResultSet()
\r
325 public ResultSet getResultSet() throws SQLException {
\r
326 return st.getResultSet();
\r
330 * @see java.sql.Statement#getWarnings()
\r
332 public SQLWarning getWarnings() throws SQLException {
\r
333 return st.getWarnings();
\r
337 * @throws SQLException
\r
338 * @see java.sql.Statement#isClosed()
\r
340 public boolean isClosed() throws SQLException {
\r
341 return st.isClosed();
\r
346 * @throws SQLException
\r
347 * @see java.sql.Statement#isPoolable()
\r
349 public boolean isPoolable() throws SQLException {
\r
350 return st.isPoolable();
\r
356 * @throws SQLException
\r
357 * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
\r
359 public boolean isWrapperFor(Class<?> iface) throws SQLException {
\r
360 return st.isWrapperFor(iface);
\r
365 * @throws SQLException
\r
366 * @see java.sql.Statement#setPoolable(boolean)
\r
368 public void setPoolable(boolean poolable) throws SQLException {
\r
369 st.setPoolable(poolable);
\r
376 * @throws SQLException
\r
377 * @see java.sql.Wrapper#unwrap(java.lang.Class)
\r
379 @SuppressWarnings("unchecked")
\r
380 public <T> T unwrap(Class<T> iface) throws SQLException {
\r
385 public void closeOnCompletion() throws SQLException {
\r
386 // TODO 自動生成されたメソッド・スタブ
\r
391 public boolean isCloseOnCompletion() throws SQLException {
\r
392 // TODO 自動生成されたメソッド・スタブ
\r