Search in sources :

Example 1 with ResultSetIterator

use of com.dexels.navajo.adapter.sqlmap.ResultSetIterator in project navajo by Dexels.

the class SQLMap method getStreamingResultSet.

@Override
public Iterator<ResultSetMap> getStreamingResultSet() throws UserException {
    requestCount++;
    ResultSet rs = null;
    long start = 0;
    if (debug || timeAlert > 0) {
        start = System.currentTimeMillis();
    }
    try {
        if (resultSet == null) {
            rs = getDBResultSet(false);
        }
        if (debug) {
            Access.writeToConsole(myAccess, "SQLMAP, QUERY HAS BEEN EXECUTED, RETRIEVING RESULTSET\n");
        }
        if (rs != null) {
            int columns = 0;
            ResultSetMetaData meta = null;
            try {
                meta = rs.getMetaData();
                columns = meta.getColumnCount();
            } catch (Exception e) {
                throw new UserException(-1, "Error getting metadata / columns", e);
            }
            // Check if previous version exists, if so, close it.
            if (myResultSetIterator != null) {
                myResultSetIterator.close();
            }
            myResultSetIterator = new ResultSetIterator(rs, meta, columns);
            return myResultSetIterator;
        } else {
            return null;
        }
    } catch (SQLException sqle) {
        sqle.printStackTrace(Access.getConsoleWriter(myAccess));
        AuditLog.log("SQLMap", sqle.getMessage(), sqle, Level.SEVERE, (myAccess != null ? (myAccess != null ? myAccess.accessID : "unknown access") : "unknown access"));
        throw new UserException(-1, sqle.getMessage(), sqle);
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSetIterator(com.dexels.navajo.adapter.sqlmap.ResultSetIterator) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) UserException(com.dexels.navajo.script.api.UserException) NavajoException(com.dexels.navajo.document.NavajoException) UserException(com.dexels.navajo.script.api.UserException) MappableException(com.dexels.navajo.script.api.MappableException) SQLException(java.sql.SQLException)

Example 2 with ResultSetIterator

use of com.dexels.navajo.adapter.sqlmap.ResultSetIterator in project navajo by Dexels.

the class JDBCMap method getStreamingResultSet.

@Override
public Iterator<ResultSetMap> getStreamingResultSet() throws UserException {
    ResultSet rs = null;
    try {
        if (resultSet == null) {
            rs = getDBResultSet(false);
        }
        if (debug) {
            Access.writeToConsole(myAccess, "SQLMAP, QUERY HAS BEEN EXECUTED, RETRIEVING RESULTSET\n");
        }
        if (rs != null) {
            int columns = 0;
            ResultSetMetaData meta = null;
            try {
                meta = rs.getMetaData();
                columns = meta.getColumnCount();
            } catch (Exception e) {
                throw new UserException(-1, "Error getting metadata / columns", e);
            }
            // Check if previous version exists, if so, close it.
            if (myResultSetIterator != null) {
                myResultSetIterator.close();
            }
            myResultSetIterator = new ResultSetIterator(rs, meta, columns);
            return myResultSetIterator;
        } else {
            return null;
        }
    } catch (SQLException sqle) {
        AuditLog.log("SQLMap", sqle.getMessage(), Level.SEVERE, (myAccess != null ? (myAccess != null ? myAccess.accessID : "unknown access") : "unknown access"));
        throw new UserException(-1, sqle.getMessage(), sqle);
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSetIterator(com.dexels.navajo.adapter.sqlmap.ResultSetIterator) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) UserException(com.dexels.navajo.script.api.UserException) UserException(com.dexels.navajo.script.api.UserException) SQLException(java.sql.SQLException) MappableException(com.dexels.navajo.script.api.MappableException) IOException(java.io.IOException)

Aggregations

ResultSetIterator (com.dexels.navajo.adapter.sqlmap.ResultSetIterator)2 MappableException (com.dexels.navajo.script.api.MappableException)2 UserException (com.dexels.navajo.script.api.UserException)2 ResultSet (java.sql.ResultSet)2 ResultSetMetaData (java.sql.ResultSetMetaData)2 SQLException (java.sql.SQLException)2 NavajoException (com.dexels.navajo.document.NavajoException)1 IOException (java.io.IOException)1