package org.opendaylight.controller.md.sal.dom.xsql.jdbc; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Statement; import java.util.ArrayList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class JDBCStatement implements Statement { private JDBCResultSet rs = null; private transient JDBCConnection connection = null; private static Map queries = new ConcurrentHashMap(); public JDBCStatement(JDBCConnection con) { this.connection = con; } public JDBCStatement() { } public static JDBCResultSet getQuery(int id) { return queries.get(id); } public static JDBCResultSet removeQuery(int id) { return queries.remove(id); } @Override public java.sql.ResultSet executeQuery(String _sql) throws SQLException { rs = new JDBCResultSet(_sql); queries.put(rs.getID(), rs); synchronized (rs) { this.connection .send(new JDBCCommand(rs, JDBCCommand.TYPE_EXECUTE_QUERY)); try { rs.wait(); } catch (Exception err) { } if (rs.getError() != null) { throw ((SQLException) rs.getError()); } } return rs; } @Override public boolean execute(String _sql) throws SQLException { return true; } public void addRecord(ArrayList hierarchy) { rs.addRecord(hierarchy); } public int size() { return rs.size(); } public void setFinished(boolean b) { this.rs.setFinished(b); } public JDBCResultSet getRS() { return this.rs; } public ResultSet getResultSet() { return this.rs; } @Override public boolean isWrapperFor(Class arg0) throws SQLException { // TODO Auto-generated method stub return false; } @Override public T unwrap(Class arg0) throws SQLException { // TODO Auto-generated method stub return null; } @Override public void addBatch(String sql) throws SQLException { // TODO Auto-generated method stub } @Override public void cancel() throws SQLException { // TODO Auto-generated method stub } @Override public void clearBatch() throws SQLException { // TODO Auto-generated method stub } @Override public void clearWarnings() throws SQLException { // TODO Auto-generated method stub } @Override public void close() throws SQLException { // TODO Auto-generated method stub } @Override public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { // TODO Auto-generated method stub return false; } @Override public boolean execute(String sql, int[] columnIndexes) throws SQLException { // TODO Auto-generated method stub return false; } @Override public boolean execute(String sql, String[] columnNames) throws SQLException { // TODO Auto-generated method stub return false; } @Override public int[] executeBatch() throws SQLException { // TODO Auto-generated method stub return null; } @Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int executeUpdate(String sql, String[] columnNames) throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int executeUpdate(String sql) throws SQLException { // TODO Auto-generated method stub return 0; } @Override public Connection getConnection() throws SQLException { // TODO Auto-generated method stub return null; } @Override public int getFetchDirection() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int getFetchSize() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public java.sql.ResultSet getGeneratedKeys() throws SQLException { // TODO Auto-generated method stub return null; } @Override public int getMaxFieldSize() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int getMaxRows() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public boolean getMoreResults() throws SQLException { // TODO Auto-generated method stub return false; } @Override public boolean getMoreResults(int current) throws SQLException { // TODO Auto-generated method stub return false; } @Override public int getQueryTimeout() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int getResultSetConcurrency() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int getResultSetHoldability() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int getResultSetType() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public int getUpdateCount() throws SQLException { // TODO Auto-generated method stub return 0; } @Override public SQLWarning getWarnings() throws SQLException { // TODO Auto-generated method stub return null; } @Override public boolean isClosed() throws SQLException { // TODO Auto-generated method stub return false; } @Override public boolean isPoolable() throws SQLException { // TODO Auto-generated method stub return false; } @Override public void setCursorName(String name) throws SQLException { // TODO Auto-generated method stub } @Override public void setEscapeProcessing(boolean enable) throws SQLException { // TODO Auto-generated method stub } @Override public void setFetchDirection(int direction) throws SQLException { // TODO Auto-generated method stub } @Override public void setFetchSize(int rows) throws SQLException { // TODO Auto-generated method stub } @Override public void setMaxFieldSize(int max) throws SQLException { // TODO Auto-generated method stub } @Override public void setMaxRows(int max) throws SQLException { // TODO Auto-generated method stub } @Override public void setPoolable(boolean poolable) throws SQLException { // TODO Auto-generated method stub } @Override public void setQueryTimeout(int seconds) throws SQLException { // TODO Auto-generated method stub } @Override public void closeOnCompletion() throws SQLException { // TODO Auto-generated method stub } @Override public boolean isCloseOnCompletion() throws SQLException { // TODO Auto-generated method stub return false; } }