Search in sources :

Example 1 with LocalProfile

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);
        }
    };
}
Also used : TeiidSQLException(org.teiid.jdbc.TeiidSQLException) ServerConnection(org.teiid.net.ServerConnection) ConnectionImpl(org.teiid.jdbc.ConnectionImpl) LocalProfile(org.teiid.jdbc.LocalProfile) TeiidException(org.teiid.core.TeiidException)

Aggregations

TeiidException (org.teiid.core.TeiidException)1 ConnectionImpl (org.teiid.jdbc.ConnectionImpl)1 LocalProfile (org.teiid.jdbc.LocalProfile)1 TeiidSQLException (org.teiid.jdbc.TeiidSQLException)1 ServerConnection (org.teiid.net.ServerConnection)1