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
;
17 JdbcSqlStatement( Connection con
)
19 jniStmt
= new JSqlStatement();
20 conn
= (JdbcSqlConnection
) con
;
21 jniStmt
.alloc(conn
.mode
);
22 jniStmt
.setConnectionPtr( conn
.getConnection().getPtr() );
26 rs
= new JdbcSqlResultSet();
28 protected void finalize ()
34 jniStmt
.free();//praba
38 System
.out
.println(e
);
41 public void prepareInt(String query
) throws SQLException
46 if(jniStmt
.isSelect()) rs
.close();
50 rv
= jniStmt
.prepare(query
);
51 if( rv
!= 0 ) // 0 ->OK
53 throw getException(CSQL_PREPARE_ERR
);
57 public boolean executeInt() throws SQLException
59 if (!isPrepared
) throw getException(CSQL_NOT_PREPARED
);
60 boolean isSelect
= jniStmt
.isSelect();
61 rowsAffect
= jniStmt
.execute();
63 throw getException(CSQL_EXECUTE_ERR
);
64 if(conn
.getAutoCommit())
70 public void close() throws SQLException
72 if(closedFlag
) return;
75 if(jniStmt
.isSelect() ) rs
.close();
77 //jniStmt.free(); Praba. this makes the stmt unusable after close
83 public void closeScan() throws SQLException
85 if( jniStmt
.isSelect()) jniStmt
.close();
88 public boolean execute (String query
) throws SQLException
94 public ResultSet
executeQuery(String query
) throws SQLException
97 if( !jniStmt
.isSelect() ) {
100 throw getException(CSQL_NOT_QUERY
);
102 boolean hasResult
= executeInt();
107 public int executeUpdate (String query
) throws SQLException
110 throw getException(CSQL_NOT_UPDATE
);
113 public Connection
getConnection() throws SQLException
117 public int getFetchDirection() throws SQLException
119 return(ResultSet
.FETCH_FORWARD
);
121 public int getFetchSize() throws SQLException
125 public ResultSet
getResultSet() throws SQLException
127 if(!jniStmt
.isSelect())
129 //praba:;changed this
133 public int getResultSetConcurrency() throws SQLException
135 return(ResultSet
.CONCUR_READ_ONLY
);
137 public int getResultSetHoldability() throws SQLException
139 return(ResultSet
.CLOSE_CURSORS_AT_COMMIT
);
141 public int getResultSetType() throws SQLException
143 return(ResultSet
.TYPE_FORWARD_ONLY
);
145 public int getUpdateCount() throws SQLException
147 if(jniStmt
.isSelect())
154 public void addBatch(String sql
) throws SQLException
156 throw getException(CSQL_NOT_SUPPORTED
);
158 public void cancel() throws SQLException
160 throw getException(CSQL_NOT_SUPPORTED
);
162 public void clearBatch() throws SQLException
164 throw getException(CSQL_NOT_SUPPORTED
);
166 public void clearWarnings() throws SQLException
168 throw getException(CSQL_NOT_SUPPORTED
);
170 public boolean execute(String sql
, int autoGeneratedKeys
) throws SQLException
172 throw getException(CSQL_NOT_SUPPORTED
);
174 public boolean execute(String sql
, int[] columnIndexes
) throws SQLException
176 throw getException(CSQL_NOT_SUPPORTED
);
178 public boolean execute(String sql
, String
[] columnNames
) throws SQLException
180 throw getException(CSQL_NOT_SUPPORTED
);
182 public int[] executeBatch() throws SQLException
184 throw getException(CSQL_NOT_SUPPORTED
);
186 public int executeUpdate(String sql
, int autoGeneratedKeys
) throws SQLException
188 throw getException(CSQL_NOT_SUPPORTED
);
190 public int executeUpdate(String sql
, int[] columnIndexes
) throws SQLException
192 throw getException(CSQL_NOT_SUPPORTED
);
194 public int executeUpdate(String sql
, String
[] columnNames
) throws SQLException
196 throw getException(CSQL_NOT_SUPPORTED
);
198 public ResultSet
getGeneratedKeys() throws SQLException
200 throw getException(CSQL_NOT_SUPPORTED
);
202 public int getMaxFieldSize() throws SQLException
204 throw getException(CSQL_NOT_SUPPORTED
);
206 public int getMaxRows() throws SQLException
208 throw getException(CSQL_NOT_SUPPORTED
);
210 public boolean getMoreResults() throws SQLException
212 throw getException(CSQL_NOT_SUPPORTED
);
214 public boolean getMoreResults( int current
) throws SQLException
216 throw getException(CSQL_NOT_SUPPORTED
);
218 public int getQueryTimeout() throws SQLException
220 throw getException(CSQL_NOT_SUPPORTED
);
222 public SQLWarning
getWarnings() throws SQLException
224 throw getException(CSQL_NOT_SUPPORTED
);
226 public void setCursorName(String name
) throws SQLException
228 throw getException(CSQL_NOT_SUPPORTED
);
230 public void setEscapeProcessing(boolean enable
) throws SQLException
232 throw getException(CSQL_NOT_SUPPORTED
);
234 public void setFetchDirection(int direction
) throws SQLException
236 throw getException(CSQL_NOT_SUPPORTED
);
238 public void setFetchSize(int rows
) throws SQLException
240 throw getException(CSQL_NOT_SUPPORTED
);
242 public void setMaxFieldSize(int max
) throws SQLException
244 throw getException(CSQL_NOT_SUPPORTED
);
246 public void setMaxRows(int maxRows
) throws SQLException
248 throw getException(CSQL_NOT_SUPPORTED
);
250 public void setQueryTimeout(int seconds
) throws SQLException
252 throw getException(CSQL_NOT_SUPPORTED
);
255 public boolean isPoolable()
259 public void setPoolable(boolean pool
)
263 public boolean isWrapperFor(Class ifact
) throws SQLException
265 throw getException(CSQL_NOT_SUPPORTED
);
267 public Class
unwrap(Class iface
) throws SQLException
269 throw getException(CSQL_NOT_SUPPORTED
);
271 public boolean isClosed()