KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nilostep > xlsql > jdbc > xlStatement


1 /*
2  * x l S Q L
3  * (c) Jim Caprioli, NiLOSTEP.com
4  * See xlSQL-license.txt for license details
5  *
6  */

7 package com.nilostep.xlsql.jdbc;
8
9 import com.nilostep.xlsql.sql.*;
10 import java.sql.*;
11
12
13 public class xlStatement implements Statement {
14     //~ Constructors ···························································
15

16     protected xlConnection xlCon;
17     private Statement dbStm;
18     /**
19     * Constructs a new StatementImpl object.
20     *
21     */

22     protected xlStatement(xlConnection con, Statement stm) throws SQLException {
23          xlCon = con;
24          dbStm = stm;
25     }
26
27     //~ Methods ································································
28

29     /**
30     * Implements method in interface java.sql.Statement
31     * @see java.sql.Statement#addBatch
32     */

33     public void addBatch(String JavaDoc sql) throws SQLException {
34         dbStm.addBatch(sql);
35     }
36
37     /**
38     * Implements method in interface java.sql.Statement
39     * @see java.sql.Statement#cancel
40     */

41     public void cancel() throws SQLException {
42         dbStm.cancel();
43     }
44
45     /**
46     * Implements method in interface java.sql.Statement
47     * @see java.sql.Statement#clearBatch
48     */

49     public void clearBatch() throws SQLException {
50         dbStm.clearBatch();
51     }
52
53     /**
54     * Implements method in interface java.sql.Statement
55     * @see java.sql.Statement#clearWarnings
56     */

57     public void clearWarnings() throws SQLException {
58         dbStm.clearWarnings();
59     }
60
61     /**
62     * Implements method in interface java.sql.Statement
63     * @see java.sql.Statement#close
64     */

65     public void close() throws SQLException {
66         dbStm.close();
67     }
68
69     /**
70     * Implements method in interface java.sql.Statement
71     * @see java.sql.Statement#execute
72     */

73     public boolean execute(String JavaDoc sql) throws SQLException {
74         boolean ret = true;
75         String JavaDoc[] sqlCommand = sql.split("[;]");
76         for (int i=0; i < sqlCommand.length; i++) {
77             xlSqlCommand cmd = xlCon.xlsql.parseSql(sqlCommand[i]);
78             if (cmd.execAllowed()) {
79                 // dbStm may throw an SQLException..., pass on to client
80
ret = dbStm.execute(sqlCommand[i]);
81                 cmd.execute();
82             }
83             else {
84                 throw new SQLException("xlSQL: execute not allowed");
85             }
86         }
87         return ret;
88     }
89
90     /**
91     * Implements method in interface java.sql.Statement
92     * @see java.sql.Statement#execute
93     */

94     public boolean execute(String JavaDoc sql, String JavaDoc[] columnNames)
95                     throws SQLException {
96         throw new SQLException("not supported");
97     }
98
99     /**
100     * Implements method in interface java.sql.Statement
101     * @see java.sql.Statement#execute
102     */

103     public boolean execute(String JavaDoc sql, int autoGeneratedKeys)
104                     throws SQLException {
105         throw new SQLException("not supported");
106     }
107
108     /**
109     * Implements method in interface java.sql.Statement
110     * @see java.sql.Statement#execute
111     */

112     public boolean execute(String JavaDoc sql, int[] columnIndexes)
113                     throws SQLException {
114         throw new SQLException("not supported");
115     }
116
117     /**
118     * Implements method in interface java.sql.Statement
119     * @see java.sql.Statement#executeBatch
120     */

121     public int[] executeBatch() throws SQLException {
122         throw new SQLException("not supported");
123     }
124
125     /**
126     * Implements method in interface java.sql.Statement
127     * @see java.sql.Statement#executeQuery
128     */

129     public ResultSet executeQuery(String JavaDoc sql) throws SQLException {
130         ResultSet dbRs = dbStm.executeQuery(sql);
131         ResultSet rs = new xlResultSet(this, dbRs);
132         return rs;
133     }
134
135     /**
136     * Implements method in interface java.sql.Statement
137     * @see java.sql.Statement#executeUpdate
138     */

139     public int executeUpdate(String JavaDoc sql) throws SQLException {
140         int ret = 0;
141         String JavaDoc[] sqlCommand = sql.split("[;]");
142         for (int i=0; i < sqlCommand.length; i++) {
143             xlSqlCommand cmd = xlCon.xlsql.parseSql(sqlCommand[i]);
144             if (cmd.execAllowed()) {
145                 // dbStm may throw an SQLException..., pass on to client
146
ret = dbStm.executeUpdate(sqlCommand[i]);
147                 cmd.execute();
148             }
149             else {
150                 throw new SQLException("xlSQL: execute not allowed");
151             }
152         }
153         return ret;
154     }
155
156     /**
157     * Implements method in interface java.sql.Statement
158     * @see java.sql.Statement#executeUpdate
159     */

160     public int executeUpdate(String JavaDoc sql, String JavaDoc[] columnNames)
161                       throws SQLException {
162         throw new SQLException("not supported");
163     }
164
165     /**
166     * Implements method in interface java.sql.Statement
167     * @see java.sql.Statement#executeUpdate
168     */

169     public int executeUpdate(String JavaDoc sql, int autoGeneratedKeys)
170                       throws SQLException {
171         throw new SQLException("not supported");
172     }
173
174     /**
175     * Implements method in interface java.sql.Statement
176     * @see java.sql.Statement#executeUpdate
177     */

178     public int executeUpdate(String JavaDoc sql, int[] columnIndexes)
179                       throws SQLException {
180         throw new SQLException("not supported");
181     }
182     
183     /**
184     * Implements method in interface java.sql.Statement
185     * @see java.sql.Statement#getConnection
186     */

187     public Connection getConnection() throws SQLException {
188         return xlCon;
189     }
190
191     /**
192     * Implements method in interface java.sql.Statement
193     * @see java.sql.Statement#getFetchDirection
194     */

195     public int getFetchDirection() throws SQLException {
196         return dbStm.getFetchDirection();
197     }
198
199     /**
200     * Implements method in interface java.sql.Statement
201     * @see java.sql.Statement#getFetchSize
202     */

203     public int getFetchSize() throws SQLException {
204         return dbStm.getFetchSize();
205     }
206
207     /**
208     * Implements method in interface java.sql.Statement
209     * @see java.sql.Statement#getGeneratedKeys
210     */

211     public ResultSet getGeneratedKeys() throws SQLException {
212         return dbStm.getGeneratedKeys();
213     }
214
215     /**
216     * Implements method in interface java.sql.Statement
217     * @see java.sql.Statement#getMaxFieldSize
218     */

219     public int getMaxFieldSize() throws SQLException {
220         return dbStm.getMaxFieldSize();
221     }
222
223     /**
224     * Implements method in interface java.sql.Statement
225     * @see java.sql.Statement#getMaxRows
226     */

227     public int getMaxRows() throws SQLException {
228         return dbStm.getMaxRows();
229     }
230
231     /**
232     * Implements method in interface java.sql.Statement
233     * @see java.sql.Statement#getMoreResults
234     */

235     public boolean getMoreResults() throws SQLException {
236         return dbStm.getMoreResults();
237     }
238
239     /**
240     * Implements method in interface java.sql.Statement
241     * @see java.sql.Statement#getMoreResults
242     */

243     public boolean getMoreResults(int current) throws SQLException {
244         return dbStm.getMoreResults(current);
245     }
246
247     /**
248     * Implements method in interface java.sql.Statement
249     * @see java.sql.Statement#getQueryTimeout
250     */

251     public int getQueryTimeout() throws SQLException {
252         return dbStm.getQueryTimeout();
253     }
254
255     /**
256     * Implements method in interface java.sql.Statement
257     * @see java.sql.Statement#getResultSet
258     */

259     public ResultSet getResultSet() throws SQLException {
260         ResultSet dbRs = dbStm.getResultSet();
261         ResultSet rs = new xlResultSet(this, dbRs);
262         return rs;
263     }
264
265     /**
266     * Implements method in interface java.sql.Statement
267     * @see java.sql.Statement#getResultSetConcurrency
268     */

269     public int getResultSetConcurrency() throws SQLException {
270         return dbStm.getResultSetConcurrency();
271     }
272
273     /**
274     * Implements method in interface java.sql.Statement
275     * @see java.sql.Statement#getResultSetHoldability
276     */

277      public int getResultSetHoldability() throws SQLException {
278         return dbStm.getResultSetHoldability();
279     }
280    
281     /**
282     * Implements method in interface java.sql.Statement
283     * @see java.sql.Statement#getResultSetType
284     */

285     public int getResultSetType() throws SQLException {
286         return dbStm.getResultSetType();
287     }
288
289     /**
290     * Implements method in interface java.sql.Statement
291     * @see java.sql.Statement#getUpdateCount
292     */

293     public int getUpdateCount() throws SQLException {
294         return dbStm.getUpdateCount();
295     }
296
297     /**
298     * Implements method in interface java.sql.Statement
299     * @see java.sql.Statement#getWarnings
300     */

301     public SQLWarning getWarnings() throws SQLException {
302         return dbStm.getWarnings();
303     }
304
305     /**
306     * Implements method in interface java.sql.Statement
307     * @see java.sql.Statement#setCursorName
308     */

309     public void setCursorName(String JavaDoc name) throws SQLException {
310         dbStm.setCursorName(name);
311     }
312
313     /**
314     * Implements method in interface java.sql.Statement
315     * @see java.sql.Statement#setEscapeProcessing
316     */

317     public void setEscapeProcessing(boolean enable) throws SQLException {
318         dbStm.setEscapeProcessing(enable);
319     }
320
321     /**
322     * Implements method in interface java.sql.Statement
323     * @see java.sql.Statement#setFetchDirection
324     */

325     public void setFetchDirection(int direction) throws SQLException {
326         dbStm.setFetchDirection(direction);
327     }
328
329     /**
330     * Implements method in interface java.sql.Statement
331     * @see java.sql.Statement#setFetchSize
332     */

333     public void setFetchSize(int rows) throws SQLException {
334         dbStm.setFetchSize(rows);
335     }
336
337     /**
338     * Implements method in interface java.sql.Statement
339     * @see java.sql.Statement#setMaxFieldSize
340     */

341     public void setMaxFieldSize(int max) throws SQLException {
342         dbStm.setMaxFieldSize(max);
343     }
344
345     /**
346     * Implements method in interface java.sql.Statement
347     * @see java.sql.Statement#setMaxRows
348     */

349     public void setMaxRows(int max) throws SQLException {
350         dbStm.setMaxRows(max);
351     }
352
353     /**
354     * Implements method in interface java.sql.Statement
355     * @see java.sql.Statement#setQueryTimeout
356     */

357     public void setQueryTimeout(int seconds) throws SQLException {
358         dbStm.setQueryTimeout(seconds);
359     }
360
361 }
Popular Tags