awips2/nativeLib/ohd.ihfsdb/src/ohd/hseb/ihfsdb/generated/ShefTsTable.java
root e2ecdcfe33 Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: a02aeb236c [formerly 9f19e3f712] [formerly a02aeb236c [formerly 9f19e3f712] [formerly 06a8b51d6d [formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]]
Former-commit-id: 06a8b51d6d
Former-commit-id: 8e80217e59 [formerly 3360eb6c5f]
Former-commit-id: 377dcd10b9
2012-01-06 08:55:05 -06:00

251 lines
9 KiB
Java

// filename: ShefTsTable.java
// author : DBGEN
// created : Tue May 31 17:52:28 CDT 2011 using database hd_ob83oax
// description: This class is used to get data from and put data into the
// shefts table of an IHFS database
//
package ohd.hseb.ihfsdb.generated;
import java.sql.*;
import java.util.*;
import ohd.hseb.db.*;
public class ShefTsTable extends DbTable
{
//-----------------------------------------------------------------
// Private data
//-----------------------------------------------------------------
private int _recordsFound = -1;
//-----------------------------------------------------------------
// ShefTsTable() - constructor to set statement variable and initialize
// number of records found to zero
//-----------------------------------------------------------------
public ShefTsTable(Database database)
{
//Constructor calls DbTable's constructor
super(database);
setTableName("shefts");
}
//-----------------------------------------------------------------
// select() - this method is called with a where clause and returns
// a List of ShefTsRecord objects
//-----------------------------------------------------------------
public List select(String where) throws SQLException
{
ShefTsRecord record = null;
// create a List to hold ShefTs Records
List recordList = new ArrayList();
// set number of records found to zero
_recordsFound = 0;
// Create the SQL statement and issue it
// construct the select statment
String selectStatement = "SELECT * FROM shefts " + where;
// get the result set back from the query to the database
ResultSet rs = getStatement().executeQuery(selectStatement);
// loop through the result set
while (rs.next())
{
// create an instance of a ShefTsRecord
// and store its address in oneRecord
record = new ShefTsRecord();
// increment the number of records found
_recordsFound++;
// assign the data returned to the result set for one
// record in the database to a ShefTsRecord object
record.setTs(getString(rs, 1));
record.setName(getString(rs, 2));
// add this ShefTsRecord object to the list
recordList.add(record);
}
// Close the result set
rs.close();
// return a List which holds the ShefTsRecord objects
return recordList;
} // end of select method
//-----------------------------------------------------------------
// selectNRecords() - this method is called with a where clause and returns
// a List filled with a maximum of maxRecordCount of ShefTsRecord objects
//-----------------------------------------------------------------
public List selectNRecords(String where, int maxRecordCount) throws SQLException
{
ShefTsRecord record = null;
// create a List to hold ShefTs Records
List recordList = new ArrayList();
// set number of records found to zero
_recordsFound = 0;
// Create the SQL statement and issue it
// construct the select statment
String selectStatement = "SELECT * FROM shefts " + where;
// get the result set back from the query to the database
ResultSet rs = getStatement().executeQuery(selectStatement);
// loop through the result set
while (rs.next())
{
// create an instance of a ShefTsRecord
// and store its address in oneRecord
record = new ShefTsRecord();
// increment the number of records found
_recordsFound++;
// assign the data returned to the result set for one
// record in the database to a ShefTsRecord object
record.setTs(getString(rs, 1));
record.setName(getString(rs, 2));
// add this ShefTsRecord object to the list
recordList.add(record);
if (_recordsFound >= maxRecordCount)
{
break;
}
}
// Close the result set
rs.close();
// return a List which holds the ShefTsRecord objects
return recordList;
} // end of selectNRecords method
//-----------------------------------------------------------------
// insert() - this method is called with a ShefTsRecord object and..
//-----------------------------------------------------------------
public int insert(ShefTsRecord record) throws SQLException
{
int returnCode=-999;
// Create a SQL insert statement and issue it
// construct the insert statement
PreparedStatement insertStatement = getConnection().prepareStatement(
" INSERT INTO shefts VALUES (?, ? )");
setString(insertStatement, 1, record.getTs());
setString(insertStatement, 2, record.getName());
// get the number of records processed by the insert
returnCode = insertStatement.executeUpdate();
return returnCode;
} // end of insert method
//-----------------------------------------------------------------
// delete() - this method is called with a where clause and returns
// the number of records deleted
//-----------------------------------------------------------------
public int delete(String where) throws SQLException
{
int returnCode=-999;
// Create a SQL delete statement and issue it
// construct the delete statement
String deleteStatement = "DELETE FROM shefts " + where;
// get the number of records processed by the delete
returnCode = getStatement().executeUpdate(deleteStatement);
return returnCode;
} // end of delete method
//-----------------------------------------------------------------
// update() - this method is called with a ShefTsRecord object and a where clause..
//-----------------------------------------------------------------
public int update(ShefTsRecord record, String where) throws SQLException
{
int returnCode=-999;
// Create a SQL update statement and issue it
// construct the update statement
PreparedStatement updateStatement = getConnection().prepareStatement(
" UPDATE shefts SET ts = ?, name = ? " + where );
setString(updateStatement, 1, record.getTs());
setString(updateStatement, 2, record.getName());
// get the number of records processed by the update
returnCode = updateStatement.executeUpdate();
return returnCode;
} // end of updateRecord method
//-----------------------------------------------------------------
// delete() - this method is called with a where clause and returns
// the number of records deleted
//-----------------------------------------------------------------
public int delete(ShefTsRecord record) throws SQLException
{
int returnCode=-999;
// Create a SQL delete statement and issue it
// construct the delete statement
String deleteStatement = "DELETE FROM shefts " + record.getWhereString();
// get the number of records processed by the delete
returnCode = getStatement().executeUpdate(deleteStatement);
return returnCode;
} // end of delete method
//-----------------------------------------------------------------
// update() - this method is called with a ShefTsRecord object and a where clause..
//-----------------------------------------------------------------
public int update(ShefTsRecord oldRecord, ShefTsRecord newRecord) throws SQLException
{
int returnCode=-999;
// Create a SQL update statement and issue it
// construct the update statement
PreparedStatement updateStatement = getConnection().prepareStatement(
" UPDATE shefts SET ts = ?, name = ? " + oldRecord.getWhereString() );
setString(updateStatement, 1, newRecord.getTs());
setString(updateStatement, 2, newRecord.getName());
// get the number of records processed by the update
returnCode = updateStatement.executeUpdate();
return returnCode;
} // end of updateRecord method
//-----------------------------------------------------------------
// insertOrUpdate() - this method is call with a ShefTsRecord object.
// the number of records inserted or updated
//-----------------------------------------------------------------
public int insertOrUpdate(ShefTsRecord record) throws SQLException
{
int returnCode=-999;
List recordList = select(record.getWhereString());
if (recordList.size() < 1)
{
returnCode = insert(record);
}
else
{
ShefTsRecord oldRecord = (ShefTsRecord) recordList.get(0);
returnCode = update(oldRecord, record);
}
return returnCode;
} // end of insertOrUpdate()
} // end of ShefTsTable class