Pessoal depois da ajuda do Daniel e do Rafael e uma leitura no artigo do Paulo Silveira(retirando o sql do seu código java). criei a seguinte arquitetura eu queria q vc dessem uma olhada e me dissem se é valida:
Bom tenho essas classes
[code]public class GerSql {
protected Properties qry;
// nao deveria estar hardcodado:
// protected static GerSql gerSql = new GerSql("arquivoMysql.txt");
public GerSql(String arquivo) {
qry = new Properties();
// le as sqls e guarda!
try {
qry.load(new FileInputStream(arquivo));
}
catch (Exception e){
String erro = (String)e.getMessage();
}
}
public PreparedStatement getPreparedStatement(Connection cx, String queryName) throws SQLException {
String qry = this.qry.getProperty(queryName);
return cx.prepareStatement(qry);
}
}[/code]
[code]public class Pessoa extends Geral{
…
//Método Cadastrar
public boolean exQuery(String qryName, ArrayList par){
GerSql ger = new GerSql(“arqSql.txt”);
try {
PreparedStatement ps = ger.getPreparedStatement(conexao, qryName);
while (n < par.size()){
ps.setString((n+1), (String)par.get(n));
n++;
}
ResultSet rs = ps.executeQuery();
}
catch ( SQLException e){
erro = e.getMessage();
}
return true;
}// fim cadastrar[/code]
e finalmente a Classe Cliente
[code] public Cliente(Connection cx){
super(cx);
}
//Método Cadastrar
public boolean cadastrar(){
query = prop.getProperty("cliente.insert");
parList.add((String)id.get(0));
parList.add((String)idEmpresa.get(0));
parList.add((String)descricao.get(0));
parList.add((String)cnpj.get(0));
exQuery(query, parList);
return true;
}// fim cadastrar[/code]
O q acham?
Estou indo pelo caminho certo?
a classe pessoa usarei para contato, empresa, etc…
:roll: