RecordSet (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.layer.location.db
Class RecordSet

    java.lang.Object
      com.bbn.openmap.layer.location.db.RecordSet

    public class RecordSet

extends java.lang.Object

The RecordSet object handles all the generic database retrieval for a SQL query. The idea is that you set it up with a connection, and set the query string that it will use to give to the database. Then, you iterate through the result set to create the objects you want to:

- Set the connection and query.
- Call next() repeatedly to see if there is data for another object.
- Use getResultSet(), which provides the result set containing the current record data. This can be done within the constructor of the data object you are trying to create.

Field Summary
`protected java.sql.Connection` | `connection` Connection object that will be used to retrieve data.
`protected static java.util.logging.Logger` | `logger`
`protected java.lang.String` | `queryString` The query string that will be executed on the database.

Constructor Summary
`RecordSet(java.sql.Connection inConnection)` Use this constructor if you want a little more control of the process.
`RecordSet(java.sql.Connection inConnection, java.lang.String query)` Does everything.

Method Summary
`void` | `close()`
`void` | `getAllQuery()` Executes "select * from 'tableName'", or whatever the queryString is set to.
`java.sql.Connection` | `getConnection()`
`java.lang.String` | `getQueryString()`
`java.sql.ResultSet` | `getResultSet()` Get the result set, after calling next.
`boolean` | `next()` This function should be called to prepare the result set with the next record set of data.
`void` | `setConnection(java.sql.Connection inConnection)`
`void` | `setQueryString(java.lang.String inQueryString)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### logger

    protected static java.util.logging.Logger logger

### connection

    protected java.sql.Connection connection

  Connection object that will be used to retrieve data.

### queryString

    protected java.lang.String queryString

  The query string that will be executed on the database.

Constructor Detail

### RecordSet

    public RecordSet(java.sql.Connection inConnection)
              throws java.sql.SQLException

  Use this constructor if you want a little more control of the process. You have to remember to set the query string and call getAllQuery() before trying to iterate through the results.

  Throws:
    `java.sql.SQLException`

### RecordSet

    public RecordSet(java.sql.Connection inConnection,
                     java.lang.String query)
              throws java.sql.SQLException

  Does everything. If the connection and query are not null, then the result set is ready for iteration after this object is created.

  Throws:
    `java.sql.SQLException`

Method Detail

### getAllQuery

    public void getAllQuery()
                     throws java.sql.SQLException

  Executes "select * from 'tableName'", or whatever the queryString is set to. If the connection is not null, and the queryString is not null, the database is fed the query statement. The result is, hopefully, that the rset (ResultSet) will be full of responses. The caller should then call next() to iterate through the results and fetch the data.

  Throws:
    `throws` - SQLException if something goes wrong with the query.
    `java.sql.SQLException`

### next

    public boolean next()
                 throws java.sql.SQLException

  This function should be called to prepare the result set with the next record set of data. Then you feed this RecordSet object to the constructor to a new data object.

  Throws:
    `java.sql.SQLException`

### getResultSet

    public java.sql.ResultSet getResultSet()

  Get the result set, after calling next. It should contain the current record's data. You have to know how to call the items, and what the type of each index is - since you set the query, you should know. You have to pay attention to the return from the next() function, though. If next() returns false, the result set won't contain valid data, or may be null.

### close

    public void close()
               throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### getConnection

    public java.sql.Connection getConnection()

### setConnection

    public void setConnection(java.sql.Connection inConnection)

### getQueryString

    public java.lang.String getQueryString()

### setQueryString

    public void setQueryString(java.lang.String inQueryString)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details