001    package railo.runtime.db.driver;
002    
003    import java.lang.reflect.InvocationTargetException;
004    import java.sql.Connection;
005    import java.sql.ResultSet;
006    import java.sql.SQLException;
007    import java.sql.SQLWarning;
008    import java.sql.Statement;
009    
010    import railo.runtime.PageContext;
011    import railo.runtime.exp.PageRuntimeException;
012    import railo.runtime.op.Caster;
013    
014    public class StatementProxy implements StatementPro {
015    
016            protected ConnectionProxy conn;
017            protected Statement stat;
018    
019            public StatementProxy(ConnectionProxy conn,Statement stat){
020                    this.conn=conn;
021                    this.stat=stat;
022            }
023            
024            @Override
025            public boolean execute(PageContext pc,String sql) throws SQLException {
026                    return stat.execute(sql);
027            }
028    
029            @Override
030            public boolean execute(PageContext pc,String sql, int autoGeneratedKeys) throws SQLException {
031                    return stat.execute(sql, autoGeneratedKeys);
032            }
033    
034            @Override
035            public boolean execute(PageContext pc,String sql, int[] columnIndexes) throws SQLException {
036                    return stat.execute(sql, columnIndexes);
037            }
038    
039            @Override
040            public boolean execute(PageContext pc,String sql, String[] columnNames) throws SQLException {
041                    return stat.execute(sql, columnNames);
042            }
043    
044            @Override
045            public ResultSet executeQuery(PageContext pc,String sql) throws SQLException {
046                    return stat.executeQuery(sql);
047            }
048    
049            @Override
050            public int executeUpdate(PageContext pc,String sql) throws SQLException {
051                    return stat.executeUpdate(sql);
052            }
053    
054            @Override
055            public int executeUpdate(PageContext pc,String sql, int autoGeneratedKeys) throws SQLException {
056                    return stat.executeUpdate(sql, autoGeneratedKeys);
057            }
058    
059            @Override
060            public int executeUpdate(PageContext pc,String sql, int[] columnIndexes) throws SQLException {
061                    return stat.executeUpdate(sql, columnIndexes);
062            }
063    
064            @Override
065            public int executeUpdate(PageContext pc,String sql, String[] columnNames) throws SQLException {
066                    return stat.executeUpdate(sql, columnNames);
067            }
068    
069    
070            @Override
071            public boolean execute(String sql) throws SQLException {
072                    return stat.execute(sql);
073            }
074    
075            @Override
076            public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
077                    return stat.execute(sql, autoGeneratedKeys);
078            }
079    
080            @Override
081            public boolean execute(String sql, int[] columnIndexes) throws SQLException {
082                    return stat.execute(sql, columnIndexes);
083            }
084    
085            @Override
086            public boolean execute(String sql, String[] columnNames) throws SQLException {
087                    return stat.execute(sql, columnNames);
088            }
089    
090            @Override
091            public int[] executeBatch() throws SQLException {
092                    return stat.executeBatch();
093            }
094    
095            @Override
096            public ResultSet executeQuery(String sql) throws SQLException {
097                    return stat.executeQuery(sql);
098            }
099    
100            @Override
101            public int executeUpdate(String sql) throws SQLException {
102                    return stat.executeUpdate(sql);
103            }
104    
105            @Override
106            public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
107                    return stat.executeUpdate(sql, autoGeneratedKeys);
108            }
109    
110            @Override
111            public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
112                    return stat.executeUpdate(sql, columnIndexes);
113            }
114    
115            @Override
116            public int executeUpdate(String sql, String[] columnNames) throws SQLException {
117                    return stat.executeUpdate(sql, columnNames);
118            }
119    
120            @Override
121            public Connection getConnection() throws SQLException {
122                    return conn;
123            }
124    
125            @Override
126            public ResultSet getGeneratedKeys() throws SQLException {
127                    return stat.getGeneratedKeys();
128            }
129    
130            @Override
131            public ResultSet getResultSet() throws SQLException {
132                    return stat.getResultSet();
133            }
134            
135            
136            
137            
138    
139            @Override
140            public boolean isWrapperFor(Class<?> iface) throws SQLException {
141                    return stat.isWrapperFor(iface);
142            }
143    
144            @Override
145            public <T> T unwrap(Class<T> iface) throws SQLException {
146                    return stat.unwrap(iface);
147            }
148    
149            @Override
150            public void addBatch(String sql) throws SQLException {
151                    stat.addBatch(sql);
152            }
153    
154            @Override
155            public void cancel() throws SQLException {
156                    stat.cancel();
157            }
158    
159            @Override
160            public void clearBatch() throws SQLException {
161                    stat.clearBatch();
162            }
163    
164            @Override
165            public void clearWarnings() throws SQLException {
166                    stat.clearWarnings();
167            }
168    
169            @Override
170            public void close() throws SQLException {
171                    stat.close();
172            }
173    
174            @Override
175            public int getFetchDirection() throws SQLException {
176                    return stat.getFetchDirection();
177            }
178    
179            @Override
180            public int getFetchSize() throws SQLException {
181                    return stat.getFetchSize();
182            }
183    
184            @Override
185            public int getMaxFieldSize() throws SQLException {
186                    return stat.getMaxFieldSize();
187            }
188    
189            @Override
190            public int getMaxRows() throws SQLException {
191                    return stat.getMaxRows();
192            }
193    
194            @Override
195            public boolean getMoreResults() throws SQLException {
196                    return stat.getMoreResults();
197            }
198    
199            @Override
200            public boolean getMoreResults(int current) throws SQLException {
201                    return stat.getMoreResults(current);
202            }
203    
204            @Override
205            public int getQueryTimeout() throws SQLException {
206                    return stat.getQueryTimeout();
207            }
208    
209            @Override
210            public int getResultSetConcurrency() throws SQLException {
211                    return stat.getResultSetConcurrency();
212            }
213    
214            @Override
215            public int getResultSetHoldability() throws SQLException {
216                    return stat.getResultSetHoldability();
217            }
218    
219            @Override
220            public int getResultSetType() throws SQLException {
221                    return stat.getResultSetType();
222            }
223    
224            @Override
225            public int getUpdateCount() throws SQLException {
226                    return stat.getUpdateCount();
227            }
228    
229            @Override
230            public SQLWarning getWarnings() throws SQLException {
231                    return stat.getWarnings();
232            }
233    
234            @Override
235            public boolean isClosed() throws SQLException {
236                    return stat.isClosed();
237            }
238    
239            @Override
240            public boolean isPoolable() throws SQLException {
241                    return stat.isPoolable();
242            }
243    
244            @Override
245            public void setCursorName(String name) throws SQLException {
246                    stat.setCursorName(name);
247            }
248    
249            @Override
250            public void setEscapeProcessing(boolean enable) throws SQLException {
251                    stat.setEscapeProcessing(enable);
252            }
253    
254            @Override
255            public void setFetchDirection(int direction) throws SQLException {
256                    stat.setFetchDirection(direction);
257            }
258    
259            @Override
260            public void setFetchSize(int rows) throws SQLException {
261                    stat.setFetchSize(rows);
262            }
263    
264            @Override
265            public void setMaxFieldSize(int max) throws SQLException {
266                    stat.setMaxFieldSize(max);
267            }
268    
269            @Override
270            public void setMaxRows(int max) throws SQLException {
271                    stat.setMaxRows(max);
272            }
273    
274            @Override
275            public void setPoolable(boolean poolable) throws SQLException {
276                    stat.setPoolable(poolable);
277            }
278    
279            @Override
280            public void setQueryTimeout(int seconds) throws SQLException {
281                    stat.setQueryTimeout(seconds);
282            }
283    
284            public void closeOnCompletion() throws SQLException {
285                    // used reflection to make sure this work with Java 5 and 6
286                    try {
287                            stat.getClass().getMethod("closeOnCompletion", new Class[0]).invoke(stat, new Object[0]);
288                    }
289                    catch (Throwable t) {
290                            if(t instanceof InvocationTargetException && ((InvocationTargetException)t).getTargetException() instanceof SQLException)
291                                    throw (SQLException)((InvocationTargetException)t).getTargetException();
292                            throw new PageRuntimeException(Caster.toPageException(t));
293                    }
294            }
295    
296            public boolean isCloseOnCompletion() throws SQLException {
297                    // used reflection to make sure this work with Java 5 and 6
298                    try {
299                            return Caster.toBooleanValue(stat.getClass().getMethod("isCloseOnCompletion", new Class[0]).invoke(stat, new Object[0]));
300                    }
301                    catch (Throwable t) {
302                            if(t instanceof InvocationTargetException && ((InvocationTargetException)t).getTargetException() instanceof SQLException)
303                                    throw (SQLException)((InvocationTargetException)t).getTargetException();
304                            throw new PageRuntimeException(Caster.toPageException(t));
305                    }
306            }
307    }