Example usage for java.sql ResultSet getTimestamp

List of usage examples for java.sql ResultSet getTimestamp

Introduction

In this page you can find the example usage for java.sql ResultSet getTimestamp.

Prototype

java.sql.Timestamp getTimestamp(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.

Usage

From source file:com.sfs.whichdoctor.dao.ProjectDAOImpl.java

/**
 * Load the project bean from the result set.
 *
 * @param rs the rs/*w w w.  j  a v  a2  s.  co  m*/
 * @return the project bean
 * @throws SQLException the sQL exception
 */
private ProjectBean loadProject(final ResultSet rs) throws SQLException {

    ProjectBean project = new ProjectBean();

    project.setId(rs.getInt("ProjectId"));
    project.setGUID(rs.getInt("GUID"));
    project.setReferenceGUID(rs.getInt("ReferenceGUID"));
    project.setAssessmentType(rs.getString("AssessmentType"));
    project.setAssessmentTypeAbbr(rs.getString("AssessmentTypeAbbr"));
    project.setProjectType(rs.getString("ProjectType"));
    project.setProjectTypeAbbr(rs.getString("ProjectTypeAbbr"));
    project.setStatus(rs.getString("Status"));
    project.setYear(rs.getInt("Year"));
    project.setAllOfProgram(rs.getBoolean("AllOfProgram"));
    project.setTitle(rs.getString("Title"));
    project.setMemo(rs.getString("Memo"));
    try {
        project.setSubmitted(rs.getDate("Submitted"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading Submitted: " + sqe.getMessage());
    }
    try {
        project.setResubmitted(rs.getDate("Resubmitted"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading Resubmitted: " + sqe.getMessage());
    }
    int assessorId1 = rs.getInt("AssessorId1");
    if (assessorId1 > 0) {
        try {
            /* Load person related to assessorId 1 */
            PersonBean person = this.personDAO.loadGUID(assessorId1);
            project.setAssessor1(person);
        } catch (Exception e) {
            dataLogger.error("Could not load PersonBean for Project");
        }
    }
    int assessorId2 = rs.getInt("AssessorId2");
    if (assessorId2 > 0) {
        try {
            /* Load person related to assessorId 2 */
            PersonBean person = this.personDAO.loadGUID(assessorId2);
            project.setAssessor2(person);
        } catch (Exception e) {
            dataLogger.error("Could not load PersonBean for Project");
        }
    }
    int assessorId3 = rs.getInt("AssessorId3");
    if (assessorId3 > 0) {
        try {
            /* Load person related to assessorId 3 */
            PersonBean person = this.personDAO.loadGUID(assessorId3);
            project.setAssessor3(person);
        } catch (Exception e) {
            dataLogger.error("Could not load PersonBean for Project");
        }
    }

    project.setTrainingOrganisation(rs.getString("TrainingOrganisation"));
    project.setTrainingProgram(rs.getString("TrainingProgram"));
    project.setTrainingProgramISBMapping(rs.getString("TrainingProgramISBMapping"));

    project.setActive(rs.getBoolean("Active"));
    try {
        project.setCreatedDate(rs.getTimestamp("CreatedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading CreatedDate: " + sqe.getMessage());
    }
    project.setCreatedBy(rs.getString("CreatedBy"));
    try {
        project.setModifiedDate(rs.getTimestamp("ModifiedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading ModifiedDate: " + sqe.getMessage());
    }
    project.setModifiedBy(rs.getString("ModifiedBy"));
    try {
        project.setExportedDate(rs.getTimestamp("ExportedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading ExportedDate: " + sqe.getMessage());
    }
    project.setExportedBy(rs.getString("ExportedBy"));

    // Load user details from DB
    UserBean user = new UserBean();
    user.setDN(rs.getString("CreatedBy"));
    user.setPreferredName(rs.getString("CreatedFirstName"));
    user.setLastName(rs.getString("CreatedLastName"));
    project.setCreatedUser(user);

    UserBean modified = new UserBean();
    modified.setDN(rs.getString("ModifiedBy"));
    modified.setPreferredName(rs.getString("ModifiedFirstName"));
    modified.setLastName(rs.getString("ModifiedLastName"));
    project.setModifiedUser(modified);

    UserBean export = new UserBean();
    export.setDN(rs.getString("ExportedBy"));
    export.setPreferredName(rs.getString("ExportedFirstName"));
    export.setLastName(rs.getString("ExportedLastName"));
    project.setExportedUser(export);

    return project;
}

From source file:org.traccar.database.QueryBuilder.java

private <T> void addProcessors(List<ResultSetProcessor<T>> processors, final Class<?> parameterType,
        final Method method, final String name) {

    if (parameterType.equals(boolean.class)) {
        processors.add(new ResultSetProcessor<T>() {
            @Override// ww w  . j  a va  2  s  . c o  m
            public void process(T object, ResultSet resultSet) throws SQLException {
                try {
                    method.invoke(object, resultSet.getBoolean(name));
                } catch (IllegalAccessException | InvocationTargetException error) {
                    Log.warning(error);
                }
            }
        });
    } else if (parameterType.equals(int.class)) {
        processors.add(new ResultSetProcessor<T>() {
            @Override
            public void process(T object, ResultSet resultSet) throws SQLException {
                try {
                    method.invoke(object, resultSet.getInt(name));
                } catch (IllegalAccessException | InvocationTargetException error) {
                    Log.warning(error);
                }
            }
        });
    } else if (parameterType.equals(long.class)) {
        processors.add(new ResultSetProcessor<T>() {
            @Override
            public void process(T object, ResultSet resultSet) throws SQLException {
                try {
                    method.invoke(object, resultSet.getLong(name));
                } catch (IllegalAccessException | InvocationTargetException error) {
                    Log.warning(error);
                }
            }
        });
    } else if (parameterType.equals(double.class)) {
        processors.add(new ResultSetProcessor<T>() {
            @Override
            public void process(T object, ResultSet resultSet) throws SQLException {
                try {
                    method.invoke(object, resultSet.getDouble(name));
                } catch (IllegalAccessException | InvocationTargetException error) {
                    Log.warning(error);
                }
            }
        });
    } else if (parameterType.equals(String.class)) {
        processors.add(new ResultSetProcessor<T>() {
            @Override
            public void process(T object, ResultSet resultSet) throws SQLException {
                try {
                    method.invoke(object, resultSet.getString(name));
                } catch (IllegalAccessException | InvocationTargetException error) {
                    Log.warning(error);
                }
            }
        });
    } else if (parameterType.equals(Date.class)) {
        processors.add(new ResultSetProcessor<T>() {
            @Override
            public void process(T object, ResultSet resultSet) throws SQLException {
                try {
                    Timestamp timestamp = resultSet.getTimestamp(name);
                    if (timestamp != null) {
                        method.invoke(object, new Date(timestamp.getTime()));
                    }
                } catch (IllegalAccessException | InvocationTargetException error) {
                    Log.warning(error);
                }
            }
        });
    } else if (parameterType.equals(byte[].class)) {
        processors.add(new ResultSetProcessor<T>() {
            @Override
            public void process(T object, ResultSet resultSet) throws SQLException {
                try {
                    method.invoke(object, resultSet.getBytes(name));
                } catch (IllegalAccessException | InvocationTargetException error) {
                    Log.warning(error);
                }
            }
        });
    } else {
        processors.add(new ResultSetProcessor<T>() {
            @Override
            public void process(T object, ResultSet resultSet) throws SQLException {
                String value = resultSet.getString(name);
                if (value != null && !value.isEmpty()) {
                    try {
                        method.invoke(object, Context.getObjectMapper().readValue(value, parameterType));
                    } catch (InvocationTargetException | IllegalAccessException | IOException error) {
                        Log.warning(error);
                    }
                }
            }
        });
    }
}

From source file:com.opencsv.ResultSetHelperService.java

private String getColumnValue(ResultSet rs, int colType, int colIndex, boolean trim, String dateFormatString,
        String timestampFormatString) throws SQLException, IOException {

    String value = "";

    switch (colType) {
    case Types.BIT:
    case Types.JAVA_OBJECT:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getObject(colIndex), "");
        value = ObjectUtils.toString(rs.getObject(colIndex), "");
        break;/*from  w w w .  j  a va 2  s.  c  om*/
    case Types.BOOLEAN:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getBoolean(colIndex));
        value = ObjectUtils.toString(rs.getBoolean(colIndex));
        break;
    case Types.NCLOB: // todo : use rs.getNClob
    case Types.CLOB:
        Clob c = rs.getClob(colIndex);
        if (c != null) {
            StrBuilder sb = new StrBuilder();
            sb.readFrom(c.getCharacterStream());
            value = sb.toString();
        }
        break;
    case Types.BIGINT:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getLong(colIndex));
        value = ObjectUtils.toString(rs.getLong(colIndex));
        break;
    case Types.DECIMAL:
    case Types.REAL:
    case Types.NUMERIC:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getBigDecimal(colIndex), "");
        value = ObjectUtils.toString(rs.getBigDecimal(colIndex), "");
        break;
    case Types.DOUBLE:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getDouble(colIndex));
        value = ObjectUtils.toString(rs.getDouble(colIndex));
        break;
    case Types.FLOAT:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getFloat(colIndex));
        value = ObjectUtils.toString(rs.getFloat(colIndex));
        break;
    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getInt(colIndex));
        value = ObjectUtils.toString(rs.getInt(colIndex));
        break;
    case Types.DATE:
        java.sql.Date date = rs.getDate(colIndex);
        if (date != null) {
            SimpleDateFormat df = new SimpleDateFormat(dateFormatString);
            value = df.format(date);
        }
        break;
    case Types.TIME:
        // Once Java 7 is the minimum supported version.
        //            value = Objects.toString(rs.getTime(colIndex), "");
        value = ObjectUtils.toString(rs.getTime(colIndex), "");
        break;
    case Types.TIMESTAMP:
        value = handleTimestamp(rs.getTimestamp(colIndex), timestampFormatString);
        break;
    case Types.NVARCHAR: // todo : use rs.getNString
    case Types.NCHAR: // todo : use rs.getNString
    case Types.LONGNVARCHAR: // todo : use rs.getNString
    case Types.LONGVARCHAR:
    case Types.VARCHAR:
    case Types.CHAR:
        String columnValue = rs.getString(colIndex);
        if (trim && columnValue != null) {
            value = columnValue.trim();
        } else {
            value = columnValue;
        }
        break;
    default:
        value = "";
    }

    if (rs.wasNull() || value == null) {
        value = "";
    }

    return value;
}

From source file:com.mirth.connect.donkey.server.data.jdbc.JdbcDao.java

private ConnectorMessage getConnectorMessageFromResultSet(String channelId, ResultSet resultSet,
        boolean includeContent, boolean includeMetaDataMap) {
    try {/* w  w w  .j  a  v a  2 s .  c o  m*/
        ConnectorMessage connectorMessage = new ConnectorMessage();
        long messageId = resultSet.getLong("message_id");
        int metaDataId = resultSet.getInt("id");
        Calendar receivedDate = Calendar.getInstance();
        receivedDate.setTimeInMillis(resultSet.getTimestamp("received_date").getTime());

        Calendar sendDate = null;
        Timestamp sendDateTimestamp = resultSet.getTimestamp("send_date");
        if (sendDateTimestamp != null) {
            sendDate = Calendar.getInstance();
            sendDate.setTimeInMillis(sendDateTimestamp.getTime());
        }

        Calendar responseDate = null;
        Timestamp responseDateTimestamp = resultSet.getTimestamp("response_date");
        if (responseDateTimestamp != null) {
            responseDate = Calendar.getInstance();
            responseDate.setTimeInMillis(responseDateTimestamp.getTime());
        }

        connectorMessage.setChannelName(getDeployedChannelName(channelId));
        connectorMessage.setMessageId(messageId);
        connectorMessage.setMetaDataId(metaDataId);
        connectorMessage.setChannelId(channelId);
        connectorMessage.setServerId(resultSet.getString("server_id"));
        connectorMessage.setConnectorName(resultSet.getString("connector_name"));
        connectorMessage.setReceivedDate(receivedDate);
        connectorMessage.setStatus(Status.fromChar(resultSet.getString("status").charAt(0)));
        connectorMessage.setSendAttempts(resultSet.getInt("send_attempts"));
        connectorMessage.setSendDate(sendDate);
        connectorMessage.setResponseDate(responseDate);
        connectorMessage.setErrorCode(resultSet.getInt("error_code"));
        connectorMessage.setChainId(resultSet.getInt("chain_id"));
        connectorMessage.setOrderId(resultSet.getInt("order_id"));

        if (includeContent) {
            if (metaDataId > 0) {
                // For destination connectors, retrieve and load any content that is stored on the source connector
                loadMessageContent(connectorMessage,
                        getDestinationMessageContentFromSource(channelId, messageId, metaDataId));
            }

            // Retrive all content for the connector and load it into the connector message
            loadMessageContent(connectorMessage, getMessageContent(channelId, messageId, metaDataId));
        }

        if (includeMetaDataMap) {
            connectorMessage.setMetaDataMap(getMetaDataMap(channelId, messageId, metaDataId));
        }
        return connectorMessage;
    } catch (SQLException e) {
        throw new DonkeyDaoException(e);
    }
}

From source file:fr.aliacom.obm.common.calendar.CalendarDaoJdbcImpl.java

private void loadEventExceptions(Connection con, AccessToken token, Map<EventObmId, Event> eventById,
        AbstractSQLCollectionHelper<?> eventIds) throws SQLException {
    String query = "SELECT " + EVENT_SELECT_FIELDS + ", eventexception_date as recurrence_id "
            + ", eventexception_parent_id as parent_id FROM Event e "
            + "LEFT JOIN EventCategory1 ON e.event_category1_id=eventcategory1_id "
            + "INNER JOIN Domain ON event_domain_id=domain_id "
            + "INNER JOIN EventEntity ON evententity_event_id=event_id "
            + "INNER JOIN UserObm o ON e.event_owner=o.userobm_id "
            + "INNER JOIN UserObm c ON e.event_usercreate=c.userobm_id "
            + "INNER JOIN EventException ON e.event_id = eventexception_child_id "
            + "WHERE eventexception_parent_id IN (" + eventIds.asPlaceHolders() + ") "
            + "OR eventexception_child_id IN (" + eventIds.asPlaceHolders() + ") ";

    PreparedStatement ps = null;//from w  w  w .j  av  a 2  s.c o m
    ResultSet rs = null;

    String domainName = null;

    Map<EventObmId, Event> evenExcepttById = new HashMap<EventObmId, Event>();
    Multimap<Event, Event> eventChildren = ArrayListMultimap.create();
    List<Event> changedEvent = new LinkedList<Event>();
    Calendar cal = getGMTCalendar();
    try {

        ps = con.prepareStatement(query);
        int nextId = eventIds.insertValues(ps, 1);
        eventIds.insertValues(ps, nextId);
        rs = ps.executeQuery();

        while (rs.next()) {
            Event eventExcept = eventFromCursor(cal, rs);
            cal.setTimeInMillis(rs.getTimestamp("recurrence_id").getTime());
            eventExcept.setRecurrenceId(cal.getTime());
            domainName = rs.getString("domain_name");
            EventObmId eventId = new EventObmId(rs.getInt("parent_id"));
            Event event = eventById.get(eventId);
            if (event != null) {
                eventChildren.put(event, eventExcept);
                changedEvent.add(eventExcept);
                evenExcepttById.put(eventExcept.getObmId(), eventExcept);
            }
        }
        IntegerIndexedSQLCollectionHelper changedIds = new IntegerIndexedSQLCollectionHelper(changedEvent);
        loadAttendees(con, evenExcepttById, domainName);
        loadAlerts(con, token, evenExcepttById, changedIds);

        for (Entry<Event, Event> entry : eventChildren.entries()) {
            entry.getKey().addEventException(entry.getValue());
        }

    } finally {
        obmHelper.cleanup(null, ps, rs);
    }
}

From source file:com.sfs.whichdoctor.dao.MembershipDAOImpl.java

/**
 * Load membership.//ww w .j a v  a2  s  . com
 *
 * @param rs the rs
 *
 * @return the membership bean
 *
 * @throws SQLException the SQL exception
 */
private MembershipBean loadMembership(final ResultSet rs) throws SQLException {

    MembershipBean membership = this.getInstance(rs.getString("MembershipClass"),
            rs.getString("MembershipType"));

    membership.setId(rs.getInt("Id"));
    membership.setGUID(rs.getInt("GUID"));
    membership.setReferenceGUID(rs.getInt("ReferenceGUID"));
    membership.setMemo(rs.getString("Memo"));

    try {
        membership.setJoinedDate(rs.getDate("JoinedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading JoinedDate: " + sqe.getMessage());
    }

    try {
        membership.setLeftDate(rs.getDate("LeftDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading LeftDate: " + sqe.getMessage());
    }

    membership.setPrimary(rs.getBoolean("PrimaryMembership"));

    for (int i = 1; i <= MAX_INTEGERS; i++) {
        String field = "intField" + i;
        membership.setIntField(i, rs.getInt(field));
    }

    for (int i = 1; i <= MAX_OBJECTTYPES; i++) {
        String field = "objecttypeField" + i;
        if (rs.getInt(field) > 0) {
            // Value exists, load objecttype bean from supplied dataset
            ObjectTypeBean objectType = loadObjectType(String.valueOf(i), rs);
            membership.setObjectTypeField(i, objectType);
        }
    }

    for (int i = 1; i <= MAX_CHARS; i++) {
        String field = "charField" + i;
        membership.setCharField(i, rs.getString(field));
    }

    for (int i = 1; i <= MAX_DATES; i++) {
        String field = "dateField" + i;
        try {
            membership.setDateField(i, rs.getDate(field));
        } catch (SQLException sqe) {
            dataLogger.debug("Error reading dateField (" + i + "): " + sqe.getMessage());
        }
    }

    membership.setActive(rs.getBoolean("Active"));
    try {
        membership.setCreatedDate(rs.getTimestamp("CreatedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading CreatedDate: " + sqe.getMessage());
    }
    membership.setCreatedBy(rs.getString("CreatedBy"));
    try {
        membership.setModifiedDate(rs.getTimestamp("ModifiedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading ModifiedDate: " + sqe.getMessage());
    }
    membership.setModifiedBy(rs.getString("ModifiedBy"));
    try {
        membership.setExportedDate(rs.getTimestamp("ExportedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading ExportedDate: " + sqe.getMessage());
    }
    membership.setExportedBy(rs.getString("ExportedBy"));

    return membership;
}

From source file:com.atlassian.jira.util.BugzillaImportBean.java

private void createCommentAndDescription(final int bug_id, final GenericValue issue) throws Exception {
    // Get description and description id for this ticket
    String description = null;/*from   w w  w.j  av a  2  s .  c om*/
    int postid = 0;

    ticketDescriptionPS.setInt(1, bug_id);

    final ResultSet DescriptionResultSet = ticketDescriptionPS.executeQuery();
    if (DescriptionResultSet.next()) {
        // @todo introduce new column for HTML? I do not think JIRA is able to parse BBCode. ;)
        description = DescriptionResultSet.getString("post_text_wiki");
        postid = DescriptionResultSet.getInt("post_id");
    }
    DescriptionResultSet.close();

    commentPS.setInt(1, bug_id);

    final ResultSet resultSet = commentPS.executeQuery();
    while (resultSet.next()) {
        // Skip if the comment is the original description post_id
        if (resultSet.getInt("post_id") == postid) {

        } else {
            final User user = getUser(resultSet.getInt("user_id"));

            /* check permissions first
            if (!permissionManager.hasPermission(Permissions.COMMENT_ISSUE, issue, user))
            {
            log("You (" + user.getFullName() + ") do not have permission to comment on an issue in project: " + projectManager.getProjectObj(
                issue.getLong("project")).getName());
            }
            else
            {*/
            final String author = user.getName();

            if (resultSet.getInt("post_private") == 1) {
                // Private post only visible by the developers role...
                // final DefaultProjectRoleManager ProjectRole = null;
                // commentManager.create(issueFactory.getIssue(issue), author, author, resultSet.getString("post_text_wiki"), null, ProjectRole.getProjectRole("Developers").getId(), resultSet.getTimestamp("created_ts"), resultSet.getTimestamp("created_ts"), false, false);
                final long RoleId = (long) 10001;
                commentManager.create(issueFactory.getIssue(issue), author, author,
                        resultSet.getString("post_text_wiki"), null, RoleId,
                        resultSet.getTimestamp("created_ts"), resultSet.getTimestamp("created_ts"), false,
                        false);
            } else {
                commentManager.create(issueFactory.getIssue(issue), author, author,
                        resultSet.getString("post_text_wiki"), null, null, resultSet.getTimestamp("created_ts"),
                        resultSet.getTimestamp("created_ts"), false, false);
            }
            //                }
        }
    }
    resultSet.close();

    issue.set("description", description);
    issue.store();
    cacheManager.flush(CacheManager.ISSUE_CACHE, issue); // Flush the cache, otherwise later when we look up the issue we'll get something stale. JRA-5542
}

From source file:com.cws.esolutions.core.dao.impl.ServerDataDAOImpl.java

/**
 * @see com.cws.esolutions.core.dao.interfaces.IServerDataDAO#getServer(java.lang.String)
 *///w  ww . j a  va 2s  . com
public synchronized List<Object> getServer(final String attribute) throws SQLException {
    final String methodName = IServerDataDAO.CNAME + "#getServer(final String attribute) throws SQLException";

    if (DEBUG) {
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("attribute: {}", attribute);
    }

    Connection sqlConn = null;
    ResultSet resultSet = null;
    CallableStatement stmt = null;
    List<Object> responseData = null;

    try {
        sqlConn = dataSource.getConnection();

        if (sqlConn.isClosed()) {
            throw new SQLException("Unable to obtain application datasource connection");
        }

        sqlConn.setAutoCommit(true);

        // we dont know what we have here - it could be a guid or it could be a hostname
        // most commonly it'll be a guid, but we're going to search anyway
        stmt = sqlConn.prepareCall("{ CALL retrServerData(?) }");
        stmt.setString(1, attribute);

        if (DEBUG) {
            DEBUGGER.debug("CallableStatement: {}", stmt);
        }

        if (stmt.execute()) {
            resultSet = stmt.getResultSet();

            if (DEBUG) {
                DEBUGGER.debug("resultSet: {}", resultSet);
            }

            if (resultSet.next()) {
                resultSet.first();

                responseData = new ArrayList<Object>(Arrays.asList(resultSet.getString(1), // T1.SYSTEM_GUID
                        resultSet.getString(2), // T1.SYSTEM_OSTYPE
                        resultSet.getString(3), // T1.SYSTEM_STATUS
                        resultSet.getString(4), // T1.SYSTEM_REGION
                        resultSet.getString(5), // T1.NETWORK_PARTITION
                        resultSet.getString(6), // T1.SYSTEM_TYPE
                        resultSet.getString(7), // T1.DOMAIN_NAME
                        resultSet.getString(8), // T1.CPU_TYPE
                        resultSet.getInt(9), // T1.CPU_COUNT
                        resultSet.getString(10), // T1.SERVER_RACK
                        resultSet.getString(11), // T1.RACK_POSITION
                        resultSet.getString(12), // T1.SERVER_MODEL
                        resultSet.getString(13), // T1.SERIAL_NUMBER
                        resultSet.getInt(14), // T1.INSTALLED_MEMORY
                        resultSet.getString(15), // T1.OPER_IP
                        resultSet.getString(16), // T1.OPER_HOSTNAME
                        resultSet.getString(17), // T1.MGMT_IP
                        resultSet.getString(18), // T1.MGMT_HOSTNAME
                        resultSet.getString(19), // T1.BKUP_IP
                        resultSet.getString(20), // T1.BKUP_HOSTNAME
                        resultSet.getString(21), // T1.NAS_IP
                        resultSet.getString(22), // T1.NAS_HOSTNAME
                        resultSet.getString(23), // T1.NAT_ADDR
                        resultSet.getString(24), // T1.COMMENTS
                        resultSet.getString(25), // T1.ASSIGNED_ENGINEER
                        resultSet.getTimestamp(26), // T1.ADD_DATE
                        resultSet.getTimestamp(27), // T1.DELETE_DATE
                        resultSet.getInt(28), // T1.DMGR_PORT
                        resultSet.getString(29), // T1.OWNING_DMGR
                        resultSet.getString(30), // T1.MGR_ENTRY
                        resultSet.getString(31), // T2.GUID
                        resultSet.getString(32))); // T2.NAME

                if (DEBUG) {
                    DEBUGGER.debug("responseData: {}", responseData);
                }
            }
        }
    } catch (SQLException sqx) {
        throw new SQLException(sqx.getMessage(), sqx);
    } finally {
        if (resultSet != null) {
            resultSet.close();
        }

        if (stmt != null) {
            stmt.close();
        }

        if ((sqlConn != null) && (!(sqlConn.isClosed()))) {
            sqlConn.close();
        }
    }

    return responseData;
}

From source file:com.uas.document.DocumentDAO.java

@Override
public ArrayList<DocumentDTO> getDeletedDocuments() {

    ArrayList<DocumentDTO> documents = null;
    DocumentDTO document = null;//  w  w w  . j  av  a 2 s.  c o  m
    ResultSet rs = null;
    Connection c = null;
    PreparedStatement ps = null;
    documents = new ArrayList<DocumentDTO>();
    try {
        c = DataSourceSingleton.getInstance().getConnection();
        String SQL = "SELECT \"object\".\"id\",\"object\".\"createdBy\", \"object\".\"name\", \"object\".\"description\", \"object\".\"createdOn\", \"object\".\"createdBy\", \"object\".\"color\", \"object\".\"kind\", \"document\".\"fileName\", \"document\".\"isFolder\", \"document\".\"deleted\", \"document\".\"fileDate\", \"document\".\"idArea\", \"object3\".\"name\" AS \"nameArea\", \"object2\".\"name\" AS \"nameCreatedBy\" FROM \"document\" JOIN \"object\" ON \"document\".\"id\" = \"object\".\"id\" JOIN \"object\" AS \"object3\" ON \"document\".\"idArea\" = \"object3\".\"id\" JOIN \"object\" AS \"object2\" ON \"object\".\"createdBy\" = \"object2\".\"id\" where \"document\".\"deleted\" = TRUE  ORDER BY \"object\".\"createdOn\" ASC";
        ps = c.prepareStatement(SQL);

        rs = ps.executeQuery();
        while (rs.next()) {
            document = new DocumentDTO();
            document.setId(rs.getInt("id"));
            document.setCreatedBy(rs.getInt("createdBy"));
            document.setIsFolder(rs.getBoolean("isFolder"));
            document.setName(rs.getString("name"));
            document.setDescription(rs.getString("description"));
            document.setColor(rs.getString("color"));
            document.setDeleted(rs.getBoolean("deleted"));
            document.setCreatedOn(rs.getTimestamp("createdOn"));
            document.setKind(rs.getString("kind"));
            document.setFilename(rs.getString("filename"));
            document.setFileDate(rs.getString("fileDate"));
            document.setIdArea(rs.getInt("idArea"));
            document.getArea().setName(rs.getString("nameArea"));
            document.getUser().setName(rs.getString("nameCreatedBy"));
            documents.add(document);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (c != null) {
                c.close();
            }
            if (ps != null) {
                ps.close();
            }

        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
    return documents;
}

From source file:com.sfs.whichdoctor.dao.PaymentDAOImpl.java

/**
 * Load payment./*from  ww w.  jav a 2  s . c  o  m*/
 *
 * @param rs the rs
 *
 * @return the payment bean
 *
 * @throws SQLException the SQL exception
 */
private PaymentBean loadPayment(final ResultSet rs) throws SQLException {
    PaymentBean payment = new PaymentBean();

    payment.setId(rs.getInt("PaymentId"));
    payment.setGUID(rs.getInt("GUID"));
    payment.setReferenceGUID(rs.getInt("ReferenceGUID"));
    if (rs.getInt("PersonId") != 0) {
        PersonBean person = new PersonBean();
        person.setGUID(rs.getInt("PersonId"));
        person.setPersonIdentifier(rs.getInt("PersonIdentifier"));
        person.setPreferredName(rs.getString("PreferredName"));
        person.setFirstName(rs.getString("FirstName"));
        person.setLastName(rs.getString("LastName"));
        person.setTitle(rs.getString("Title"));

        payment.setPerson(person);
    }
    if (rs.getInt("OrganisationId") > 0) {
        OrganisationBean organisation = new OrganisationBean();
        organisation.setGUID(rs.getInt("OrganisationId"));
        organisation.setName(rs.getString("OrganisationName"));
        payment.setOrganisation(organisation);
    }
    if (rs.getInt("IncomeStreamId") > 0) {
        /* Payment is a negative payment */
        payment.setNegativePayment(true);
        /* Create a 'positive' value */
        payment.setIncomeStream(rs.getString("IncomeStream"));
        payment.setIncomeStreamId(rs.getInt("IncomeStreamId"));
    } else {
        payment.setNegativePayment(false);
        /* See if 'positive' payment has attributed invoice */
        if (rs.getInt("InvoiceId") > 0) {
            DebitBean debit = new DebitBean();
            debit.setGUID(rs.getInt("InvoiceId"));
            debit.setDescription(rs.getString("Description"));
            debit.setTypeName(rs.getString("DebitType"));
            debit.setNumber(rs.getString("InvoiceNo"));
            debit.setAbbreviation(rs.getString("Abbreviation"));
            try {
                debit.setIssued(rs.getDate("Issued"));
            } catch (Exception sqe) {
                dataLogger.debug("Error parsing Issued value: " + sqe.getMessage());
            }
            debit.setGSTRate(rs.getDouble("InvoiceGSTRate"));
            debit.setCancelled(rs.getBoolean("InvoiceCancelled"));
            debit.setValue(rs.getDouble("InvoiceValue"));
            debit.setCreditValue(rs.getDouble("InvoiceCreditValue"));
            debit.setNetValue(rs.getDouble("InvoiceNetValue"));

            payment.setDebit(debit);
        }
    }
    payment.setValue(rs.getDouble("Value"));
    payment.setNetValue(rs.getDouble("NetValue"));
    payment.setGSTRate(rs.getDouble("GSTRate"));

    payment.setActive(rs.getBoolean("Active"));
    try {
        payment.setCreatedDate(rs.getTimestamp("CreatedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading CreatedDate: " + sqe.getMessage());
    }
    payment.setCreatedBy(rs.getString("CreatedBy"));
    try {
        payment.setModifiedDate(rs.getTimestamp("ModifiedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading ModifiedDate: " + sqe.getMessage());
    }
    payment.setModifiedBy(rs.getString("ModifiedBy"));
    try {
        payment.setExportedDate(rs.getTimestamp("ExportedDate"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error reading ExportedDate: " + sqe.getMessage());
    }
    payment.setExportedBy(rs.getString("ExportedBy"));

    return payment;
}