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
;
18 JdbcSqlStatement( Connection con
)
20 jniStmt
= new JSqlStatement();
21 conn
= (JdbcSqlConnection
) con
;
22 jniStmt
.alloc(conn
.mode
);
23 jniStmt
.setConnectionPtr( conn
.getConnection().getPtr() );
28 rs
= new JdbcSqlResultSet();
30 protected void finalize ()
36 jniStmt
.free();//praba
40 System
.out
.println(e
);
43 public void prepareInt(String query
) throws SQLException
48 if(isSelect
) rs
.close();
53 rv
= jniStmt
.prepare(query
);
54 if( rv
!= 0 ) // 0 ->OK
56 throw getException(CSQL_PREPARE_ERR
);
58 isSelect
= jniStmt
.isSelect();
61 public boolean executeInt() throws SQLException
63 if (!isPrepared
) throw getException(CSQL_NOT_PREPARED
);
64 rowsAffect
= jniStmt
.execute();
66 throw getException(CSQL_EXECUTE_ERR
);
67 if(conn
.getAutoCommit())
73 public void close() throws SQLException
75 if(closedFlag
) return;
78 if(isSelect
) rs
.close();
80 //jniStmt.free(); Praba. this makes the stmt unusable after close
86 public void closeScan() throws SQLException
88 if(isSelect
) jniStmt
.close();
91 public boolean execute (String query
) throws SQLException
97 public ResultSet
executeQuery(String query
) throws SQLException
103 throw getException(CSQL_NOT_QUERY
);
105 boolean hasResult
= executeInt();
110 public int executeUpdate (String query
) throws SQLException
113 throw getException(CSQL_NOT_UPDATE
);
116 public Connection
getConnection() throws SQLException
120 public int getFetchDirection() throws SQLException
122 return(ResultSet
.FETCH_FORWARD
);
124 public int getFetchSize() throws SQLException
128 public ResultSet
getResultSet() throws SQLException
132 if(closedFlag
) throw getException( CSQL_INVALID_STATE
);
136 public int getResultSetConcurrency() throws SQLException
138 return(ResultSet
.CONCUR_READ_ONLY
);
140 public int getResultSetHoldability() throws SQLException
142 return(ResultSet
.CLOSE_CURSORS_AT_COMMIT
);
144 public int getResultSetType() throws SQLException
146 return(ResultSet
.TYPE_FORWARD_ONLY
);
148 public int getUpdateCount() throws SQLException
157 public void addBatch(String sql
) throws SQLException
159 throw getException(CSQL_NOT_SUPPORTED
);
161 public void cancel() throws SQLException
163 throw getException(CSQL_NOT_SUPPORTED
);
165 public void clearBatch() throws SQLException
167 throw getException(CSQL_NOT_SUPPORTED
);
169 public void clearWarnings() throws SQLException
171 throw getException(CSQL_NOT_SUPPORTED
);
173 public boolean execute(String sql
, int autoGeneratedKeys
) throws SQLException
175 throw getException(CSQL_NOT_SUPPORTED
);
177 public boolean execute(String sql
, int[] columnIndexes
) throws SQLException
179 throw getException(CSQL_NOT_SUPPORTED
);
181 public boolean execute(String sql
, String
[] columnNames
) throws SQLException
183 throw getException(CSQL_NOT_SUPPORTED
);
185 public int[] executeBatch() throws SQLException
187 throw getException(CSQL_NOT_SUPPORTED
);
189 public int executeUpdate(String sql
, int autoGeneratedKeys
) throws SQLException
191 throw getException(CSQL_NOT_SUPPORTED
);
193 public int executeUpdate(String sql
, int[] columnIndexes
) throws SQLException
195 throw getException(CSQL_NOT_SUPPORTED
);
197 public int executeUpdate(String sql
, String
[] columnNames
) throws SQLException
199 throw getException(CSQL_NOT_SUPPORTED
);
201 public ResultSet
getGeneratedKeys() throws SQLException
203 throw getException(CSQL_NOT_SUPPORTED
);
205 public int getMaxFieldSize() throws SQLException
207 throw getException(CSQL_NOT_SUPPORTED
);
209 public int getMaxRows() throws SQLException
211 throw getException(CSQL_NOT_SUPPORTED
);
213 public boolean getMoreResults() throws SQLException
215 throw getException(CSQL_NOT_SUPPORTED
);
217 public boolean getMoreResults( int current
) throws SQLException
219 throw getException(CSQL_NOT_SUPPORTED
);
221 public int getQueryTimeout() throws SQLException
223 throw getException(CSQL_NOT_SUPPORTED
);
225 public SQLWarning
getWarnings() throws SQLException
227 throw getException(CSQL_NOT_SUPPORTED
);
229 public void setCursorName(String name
) throws SQLException
231 throw getException(CSQL_NOT_SUPPORTED
);
233 public void setEscapeProcessing(boolean enable
) throws SQLException
235 throw getException(CSQL_NOT_SUPPORTED
);
237 public void setFetchDirection(int direction
) throws SQLException
239 throw getException(CSQL_NOT_SUPPORTED
);
241 public void setFetchSize(int rows
) throws SQLException
243 throw getException(CSQL_NOT_SUPPORTED
);
245 public void setMaxFieldSize(int max
) throws SQLException
247 throw getException(CSQL_NOT_SUPPORTED
);
249 public void setMaxRows(int maxRows
) throws SQLException
251 throw getException(CSQL_NOT_SUPPORTED
);
253 public void setQueryTimeout(int seconds
) throws SQLException
255 throw getException(CSQL_NOT_SUPPORTED
);
258 public boolean isPoolable()
262 public void setPoolable(boolean pool
)
266 public boolean isWrapperFor(Class ifact
) throws SQLException
268 throw getException(CSQL_NOT_SUPPORTED
);
270 public Class
unwrap(Class iface
) throws SQLException
272 throw getException(CSQL_NOT_SUPPORTED
);
274 public boolean isClosed()