org.neogroup.warp.data.DataConnection Maven / Gradle / Ivy
package org.neogroup.warp.data;
import org.neogroup.warp.data.query.*;
import org.neogroup.warp.data.query.builders.QueryBuilder;
import java.sql.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static org.neogroup.warp.Warp.getLogger;
public class DataConnection {
private final Connection connection;
private final QueryBuilder queryBuilder;
protected DataConnection(Connection connection, QueryBuilder queryBuilder) {
this.connection = connection;
this.queryBuilder = queryBuilder;
}
public void close() {
try {
connection.close();
}
catch (Exception ex ) {
throw new RuntimeException(ex);
}
}
public boolean isClosed() {
try {
return connection.isClosed();
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public void setReadOnly(boolean readOnly) {
try {
connection.setReadOnly(readOnly);
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public boolean isReadOnly() {
try {
return connection.isReadOnly();
}
catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public DataTable getTable(String table) {
return new DataTable(this, table);
}
public Collection query(Query query) {
List