1 package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
3 import java.sql.Connection;
4 import java.sql.ResultSet;
5 import java.sql.SQLException;
6 import java.sql.SQLWarning;
7 import java.sql.Statement;
8 import java.util.ArrayList;
10 import java.util.concurrent.ConcurrentHashMap;
12 public class JDBCStatement implements Statement {
13 private JDBCResultSet rs = null;
14 private transient JDBCConnection connection = null;
15 private static Map<Integer, JDBCResultSet> queries =
16 new ConcurrentHashMap<Integer, JDBCResultSet>();
18 public JDBCStatement(JDBCConnection con) {
19 this.connection = con;
22 public JDBCStatement() {
26 public static JDBCResultSet getQuery(int id) {
27 return queries.get(id);
30 public static JDBCResultSet removeQuery(int id) {
31 return queries.remove(id);
35 public java.sql.ResultSet executeQuery(String _sql) throws SQLException {
36 rs = new JDBCResultSet(_sql);
37 queries.put(rs.getID(), rs);
40 .send(new JDBCCommand(rs, JDBCCommand.TYPE_EXECUTE_QUERY));
43 } catch (Exception err) {
45 if (rs.getError() != null) {
46 throw ((SQLException) rs.getError());
53 public boolean execute(String _sql) throws SQLException {
57 public void addRecord(ArrayList hierarchy) {
58 rs.addRecord(hierarchy);
65 public void setFinished(boolean b) {
66 this.rs.setFinished(b);
69 public JDBCResultSet getRS() {
73 public ResultSet getResultSet() {
78 public boolean isWrapperFor(Class<?> arg0) throws SQLException {
79 // TODO Auto-generated method stub
84 public <T> T unwrap(Class<T> arg0) throws SQLException {
85 // TODO Auto-generated method stub
90 public void addBatch(String sql) throws SQLException {
91 // TODO Auto-generated method stub
96 public void cancel() throws SQLException {
97 // TODO Auto-generated method stub
102 public void clearBatch() throws SQLException {
103 // TODO Auto-generated method stub
108 public void clearWarnings() throws SQLException {
109 // TODO Auto-generated method stub
114 public void close() throws SQLException {
115 // TODO Auto-generated method stub
120 public boolean execute(String sql, int autoGeneratedKeys)
121 throws SQLException {
122 // TODO Auto-generated method stub
127 public boolean execute(String sql, int[] columnIndexes)
128 throws SQLException {
129 // TODO Auto-generated method stub
134 public boolean execute(String sql, String[] columnNames)
135 throws SQLException {
136 // TODO Auto-generated method stub
141 public int[] executeBatch() throws SQLException {
142 // TODO Auto-generated method stub
147 public int executeUpdate(String sql, int autoGeneratedKeys)
148 throws SQLException {
149 // TODO Auto-generated method stub
154 public int executeUpdate(String sql, int[] columnIndexes)
155 throws SQLException {
156 // TODO Auto-generated method stub
161 public int executeUpdate(String sql, String[] columnNames)
162 throws SQLException {
163 // TODO Auto-generated method stub
168 public int executeUpdate(String sql) throws SQLException {
169 // TODO Auto-generated method stub
174 public Connection getConnection() throws SQLException {
175 // TODO Auto-generated method stub
180 public int getFetchDirection() throws SQLException {
181 // TODO Auto-generated method stub
186 public int getFetchSize() throws SQLException {
187 // TODO Auto-generated method stub
192 public java.sql.ResultSet getGeneratedKeys() throws SQLException {
193 // TODO Auto-generated method stub
198 public int getMaxFieldSize() throws SQLException {
199 // TODO Auto-generated method stub
204 public int getMaxRows() throws SQLException {
205 // TODO Auto-generated method stub
210 public boolean getMoreResults() throws SQLException {
211 // TODO Auto-generated method stub
216 public boolean getMoreResults(int current) throws SQLException {
217 // TODO Auto-generated method stub
222 public int getQueryTimeout() throws SQLException {
223 // TODO Auto-generated method stub
228 public int getResultSetConcurrency() throws SQLException {
229 // TODO Auto-generated method stub
234 public int getResultSetHoldability() throws SQLException {
235 // TODO Auto-generated method stub
240 public int getResultSetType() throws SQLException {
241 // TODO Auto-generated method stub
246 public int getUpdateCount() throws SQLException {
247 // TODO Auto-generated method stub
252 public SQLWarning getWarnings() throws SQLException {
253 // TODO Auto-generated method stub
258 public boolean isClosed() throws SQLException {
259 // TODO Auto-generated method stub
264 public boolean isPoolable() throws SQLException {
265 // TODO Auto-generated method stub
270 public void setCursorName(String name) throws SQLException {
271 // TODO Auto-generated method stub
276 public void setEscapeProcessing(boolean enable) throws SQLException {
277 // TODO Auto-generated method stub
282 public void setFetchDirection(int direction) throws SQLException {
283 // TODO Auto-generated method stub
288 public void setFetchSize(int rows) throws SQLException {
289 // TODO Auto-generated method stub
294 public void setMaxFieldSize(int max) throws SQLException {
295 // TODO Auto-generated method stub
300 public void setMaxRows(int max) throws SQLException {
301 // TODO Auto-generated method stub
306 public void setPoolable(boolean poolable) throws SQLException {
307 // TODO Auto-generated method stub
312 public void setQueryTimeout(int seconds) throws SQLException {
313 // TODO Auto-generated method stub
318 public void closeOnCompletion() throws SQLException {
319 // TODO Auto-generated method stub
324 public boolean isCloseOnCompletion() throws SQLException {
325 // TODO Auto-generated method stub