use of org.teiid.jdbc.LocalProfile in project teiid by teiid.
the class CommandContext method getConnection.
@Override
public TeiidConnection getConnection() throws TeiidSQLException {
LocalProfile ep = getDQPWorkContext().getConnectionProfile();
// TODO: this is problematic as the client properties are not conveyed
Properties info = new Properties();
info.put(LocalProfile.DQP_WORK_CONTEXT, getDQPWorkContext());
// $NON-NLS-1$ //$NON-NLS-2$
String url = "jdbc:teiid:" + getVdbName() + "." + getVdbVersion();
ServerConnection sc;
try {
sc = ep.createServerConnection(info);
} catch (TeiidException e) {
throw TeiidSQLException.create(e);
}
return new ConnectionImpl(sc, info, url) {
@Override
public void close() throws SQLException {
// just ignore
}
@Override
public void rollback() throws SQLException {
// just ignore
}
@Override
public void setAutoCommit(boolean autoCommit) throws SQLException {
// TODO: detect if attempted set conflicts with current txn state
throw new TeiidSQLException();
}
@Override
public void commit() throws SQLException {
throw new TeiidSQLException();
}
@Override
public void changeUser(String userName, String newPassword) throws SQLException {
throw new TeiidSQLException();
}
@Override
protected synchronized long nextRequestID() {
// need to choose ids that won't conflict with the user connection
return -(long) (Math.random() * Long.MAX_VALUE);
}
};
}
Aggregations