use of net.idea.modbcum.i.exceptions.DbAmbitException in project ambit-mirror by ideaconsult.
the class AmbitRows method open.
public synchronized void open() throws DbAmbitException {
if (query == null)
throw new DbAmbitException("Query not defined!");
setReady(false);
try {
close();
// rowset.close();
} catch (Exception x) {
logger.log(Level.WARNING, x.getMessage(), x);
}
if (getConnection() != null)
executor.setConnection(connection);
executor.open();
try {
populate(executor.process(query));
} catch (AmbitException x) {
throw new DbAmbitException(x);
} catch (SQLException x) {
throw new DbAmbitException(x);
} finally {
setReady(true);
}
}
use of net.idea.modbcum.i.exceptions.DbAmbitException in project ambit-mirror by ideaconsult.
the class OntologyEditor method setConnection.
/**
* query[side.ordinal()].setValue(((Dictionary)selected).getTemplate());
* rows[side.ordinal()].setQuery(query[side.ordinal()]);
*/
/*
* (non-Javadoc)
* @see ambit2.db.AbstractDBProcessor#setConnection(java.sql.Connection)
*/
@Override
public void setConnection(Connection connection) throws DbAmbitException {
super.setConnection(connection);
for (SIDE side : SIDE.values()) {
rows[side.ordinal()].setConnection(connection);
try {
rows[side.ordinal()].setQuery(query[side.ordinal()]);
} catch (Exception x) {
x.printStackTrace();
}
}
processor.setConnection(connection);
}
use of net.idea.modbcum.i.exceptions.DbAmbitException in project ambit-mirror by ideaconsult.
the class RepositoryReader method open.
public void open() throws DbAmbitException {
try {
prepareStatement(connection);
ps_structures.clearParameters();
rs = ps_structures.executeQuery();
} catch (SQLException x) {
throw new DbAmbitException(null, x);
}
}
use of net.idea.modbcum.i.exceptions.DbAmbitException in project ambit-mirror by ideaconsult.
the class ProcessorCreateQuery method insertScreenedResults.
protected int insertScreenedResults(IStoredQuery result, final IQueryRetrieval<IStructureRecord> query) throws SQLException, AmbitException {
final PreparedStatement insertGoodResults = connection.prepareStatement(IStoredQuery.SQL_INSERT + " values(?,?,?,1,?,?)");
QueryStructureReporter<IQueryRetrieval<IStructureRecord>, IStructureRecord> reporter = new QueryStructureReporter<IQueryRetrieval<IStructureRecord>, IStructureRecord>() {
@Override
public void close() throws Exception {
// TODO Auto-generated method stub
super.close();
}
@Override
public void header(IStructureRecord output, IQueryRetrieval<IStructureRecord> query) {
// TODO Auto-generated method stub
}
@Override
public Object processItem(IStructureRecord record) throws AmbitException {
try {
insertGoodResults.setInt(1, query.getId());
insertGoodResults.setInt(2, record.getIdchemical());
insertGoodResults.setInt(3, record.getIdstructure());
insertGoodResults.setDouble(4, 1);
insertGoodResults.setNull(5, Types.VARCHAR);
insertGoodResults.executeUpdate();
} catch (Exception x) {
throw new AmbitException(x);
}
return null;
}
public void open() throws DbAmbitException {
}
@Override
public void footer(IStructureRecord output, IQueryRetrieval<IStructureRecord> query) {
// TODO Auto-generated method stub
}
};
try {
long timeout = 8 * 1000;
try {
timeout = Long.parseLong(Preferences.getProperty(Preferences.TIMEOUT));
} catch (Exception x) {
}
// 1s
reporter.setTimeout(timeout);
reporter.setAutoCommit(true);
reporter.setConnection(connection);
reporter.process(query);
} catch (Exception x) {
logger.log(Level.WARNING, x.getMessage(), x);
} finally {
try {
insertGoodResults.close();
} catch (Exception x) {
logger.log(Level.FINEST, x.getMessage(), x);
}
try {
reporter.close();
} catch (Exception x) {
logger.log(Level.FINEST, x.getMessage(), x);
}
}
return 1;
}
Aggregations