Is it possible to pass my class constructor a record from a recordset object? So inside my class I have variables for all the information coming from the database and I just want to do something like this:
Thanks for any help!
Leslie
Have you met Hardy Heron?
Code:
package model;
import java.util.ArrayList;
import java.util.List;
import java.sql.*;
public class Statute {
String statuteNumber;
String chargeAbbrev;
boolean active;
String shortDescrip;
String extendedDescrip;
String ncic_id;
String effectiveDate;
boolean mandatoryCourt;
int fineAmount;
int bondAmount;
String chargeType;
String chargeCategory;
String crimHistory;
String origin;
String crStatute;
String user;
String lastUpdate;
String chargeSubCategory;
String Prefix;
[b] Statute(recordObject From Database){
/*assign values from database records to class variables*/
}[/b]
public List getStatutes(String status, String origin){
/*List<Statute> statutes = new ArrayList<Statute>();*/
String library = "CMLIB";
String statusClause = null;
String originClause = null;
if (status.equals("Inactive")){
statusClause = "STASTS='I'";
}
else if (status.equals("Active")){
statusClause = "STASTS<>'I'";
}
if (origin.equals("City")){
originClause = "ORIGIN = 'C'";
}
else if (origin.equals("County")){
originClause = "ORIGIN = 'N'";
}
else if (origin.equals("State")){
originClause = "ORIGIN = 'S'";
}
else if (origin.equals("Local")){
originClause = "ORIGIN = 'L'";
}
List statutes = new ArrayList();
try
{
jdbcAccess datasource = new jdbcAccess();
datasource.connect();
Connection conn = datasource.getConnection();
Statement sqlstmt = conn.createStatement();
String stmt = "SELECT * FROM " + library + "CMPSTAMFE E INNER JOIN " + library +
"CMPSTAMF M ON E.STATUT = M.STATUT AND E.CHGABV = M.CHGABV";
/*build WHERE clause based on values determined above*/
ResultSet rsStatutes = sqlstmt.executeQuery(stmt);
while(rsStatutes.next()){
[b]statutes.add(new Statute(rsStatutes.record));[/b]
}
}
catch (SQLException sql)
{
System.out.println("statute Access - Sql Exception: " + sql.getMessage());
}
return(statutes);
}
}
Leslie
Have you met Hardy Heron?