2 import java
.sql
.Connection
;
3 import java
.sql
.Statement
;
4 import java
.sql
.SQLException
;
5 import java
.sql
.ResultSet
;
6 import java
.sql
.SQLWarning
;
8 public class JdbcSqlStatement
extends JSqlError
implements Statement
, JSqlErrorType
10 public boolean closedFlag
;
11 public boolean isPrepared
;
12 public int rowsAffect
;
13 public JSqlStatement jniStmt
;
14 public JdbcSqlConnection conn
;
15 public JdbcSqlResultSet rs
;
16 public boolean isSelect
;
17 public boolean isFirstExecute
;
19 JdbcSqlStatement( Connection con
)
21 jniStmt
= new JSqlStatement();
22 isFirstExecute
= false;
23 conn
= (JdbcSqlConnection
) con
;
24 jniStmt
.alloc(conn
.mode
);
25 jniStmt
.setConnectionPtr( conn
.getConnection().getPtr() );
30 rs
= new JdbcSqlResultSet();
32 protected void finalize ()
38 jniStmt
.free();//praba
42 System
.out
.println(e
);
45 public void prepareInt(String query
) throws SQLException
50 if(isSelect
) rs
.close();
53 isFirstExecute
= false;
56 rv
= jniStmt
.prepare(query
);
57 if( rv
!= 0 ) // 0 ->OK
59 throw getException(CSQL_PREPARE_ERR
);
61 isSelect
= jniStmt
.isSelect();
63 isFirstExecute
= true;
65 public boolean executeInt() throws SQLException
67 if (!isPrepared
) throw getException(CSQL_NOT_PREPARED
);
68 rowsAffect
= jniStmt
.execute();
70 throw getException(CSQL_EXECUTE_ERR
);
71 if(conn
.getAutoCommit())
77 public void close() throws SQLException
79 if(closedFlag
) return;
82 if(isSelect
) rs
.close();
84 //jniStmt.free(); Praba. this makes the stmt unusable after close
90 public void closeScan() throws SQLException
92 if(isSelect
) jniStmt
.close();
95 public boolean execute (String query
) throws SQLException
101 public ResultSet
executeQuery(String query
) throws SQLException
107 isFirstExecute
= false;
108 throw getException(CSQL_NOT_QUERY
);
110 boolean hasResult
= executeInt();
116 public int executeUpdate (String query
) throws SQLException
119 throw getException(CSQL_NOT_UPDATE
);
122 public Connection
getConnection() throws SQLException
126 public int getFetchDirection() throws SQLException
128 return(ResultSet
.FETCH_FORWARD
);
130 public int getFetchSize() throws SQLException
134 public ResultSet
getResultSet() throws SQLException
138 if(closedFlag
) throw getException( CSQL_INVALID_STATE
);
142 public int getResultSetConcurrency() throws SQLException
144 return(ResultSet
.CONCUR_READ_ONLY
);
146 public int getResultSetHoldability() throws SQLException
148 return(ResultSet
.CLOSE_CURSORS_AT_COMMIT
);
150 public int getResultSetType() throws SQLException
152 return(ResultSet
.TYPE_FORWARD_ONLY
);
154 public int getUpdateCount() throws SQLException
158 // return rowsAffect;
163 public void addBatch(String sql
) throws SQLException
165 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::addBatch called");
166 throw getException(CSQL_NOT_SUPPORTED
);
168 public void cancel() throws SQLException
170 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::cancel called");
171 throw getException(CSQL_NOT_SUPPORTED
);
173 public void clearBatch() throws SQLException
175 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::clearBatch called");
176 throw getException(CSQL_NOT_SUPPORTED
);
178 public void clearWarnings() throws SQLException
183 public boolean execute(String sql
, int autoGeneratedKeys
) throws SQLException
185 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::execute called");
186 throw getException(CSQL_NOT_SUPPORTED
);
188 public boolean execute(String sql
, int[] columnIndexes
) throws SQLException
190 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::execute called");
191 throw getException(CSQL_NOT_SUPPORTED
);
193 public boolean execute(String sql
, String
[] columnNames
) throws SQLException
195 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::execute called");
196 throw getException(CSQL_NOT_SUPPORTED
);
198 public int[] executeBatch() throws SQLException
200 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::executeBatch called");
201 throw getException(CSQL_NOT_SUPPORTED
);
203 public int executeUpdate(String sql
, int autoGeneratedKeys
) throws SQLException
205 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::executeUpdate called");
206 throw getException(CSQL_NOT_SUPPORTED
);
208 public int executeUpdate(String sql
, int[] columnIndexes
) throws SQLException
210 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::executeUpdate called");
211 throw getException(CSQL_NOT_SUPPORTED
);
213 public int executeUpdate(String sql
, String
[] columnNames
) throws SQLException
215 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::executeUpdate called");
216 throw getException(CSQL_NOT_SUPPORTED
);
218 public ResultSet
getGeneratedKeys() throws SQLException
220 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::getGeneratedKeys called");
221 throw getException(CSQL_NOT_SUPPORTED
);
223 public int getMaxFieldSize() throws SQLException
225 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::getMaxFieldSize called");
226 throw getException(CSQL_NOT_SUPPORTED
);
228 public int getMaxRows() throws SQLException
232 //if (JSqlError.isDebug) System.out.println("JdbcSqlStatement:;getMaxRows called");
233 //throw getException(CSQL_NOT_SUPPORTED);
235 public boolean getMoreResults() throws SQLException
237 // if (JSqlError.isDebug) System.out.println("JdbcSqlStatement::getMoreResults called");
238 //throw getException(CSQL_NOT_SUPPORTED);
241 public boolean getMoreResults( int current
) throws SQLException
243 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::getMoreResults(int) called");
244 throw getException(CSQL_NOT_SUPPORTED
);
246 public int getQueryTimeout() throws SQLException
248 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::getQueryTimeout called");
249 throw getException(CSQL_NOT_SUPPORTED
);
251 public SQLWarning
getWarnings() throws SQLException
253 //TODO information present in Action Item
256 public void setCursorName(String name
) throws SQLException
258 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::setCursorName called");
259 throw getException(CSQL_NOT_SUPPORTED
);
261 public void setEscapeProcessing(boolean enable
) throws SQLException
263 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::setEscapeProcessing called");
264 throw getException(CSQL_NOT_SUPPORTED
);
266 public void setFetchDirection(int direction
) throws SQLException
268 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::setFetchDirection called");
269 throw getException(CSQL_NOT_SUPPORTED
);
271 public void setFetchSize(int rows
) throws SQLException
273 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::setFetchSize called");
274 throw getException(CSQL_NOT_SUPPORTED
);
276 public void setMaxFieldSize(int max
) throws SQLException
278 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::setMaxFieldSize called");
279 throw getException(CSQL_NOT_SUPPORTED
);
281 public void setMaxRows(int maxRows
) throws SQLException
285 // if (JSqlError.isDebug) System.out.println("JdbcSqlStatement::setMaxRows called");
286 //throw getException(CSQL_NOT_SUPPORTED);
288 public void setQueryTimeout(int seconds
) throws SQLException
290 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::setQueryTimeout called");
291 throw getException(CSQL_NOT_SUPPORTED
);
294 public boolean isPoolable()
298 public void setPoolable(boolean pool
)
302 public boolean isWrapperFor(Class ifact
) throws SQLException
304 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::isWrapperFor called");
305 throw getException(CSQL_NOT_SUPPORTED
);
307 public Class
unwrap(Class iface
) throws SQLException
309 if (JSqlError
.isDebug
) System
.out
.println("JdbcSqlStatement::unwrap called");
310 throw getException(CSQL_NOT_SUPPORTED
);
312 public boolean isClosed()