public void cadastrarOrdemServico(OrdemServico os) throws SQLException {
String sql = "INSERT INTO SERVICO_ABERTO (servico, valor, valorTotal) " +
"VALUES (?, ?, ?)";
PreparedStatement comandoSQL = (PreparedStatement) banco.getConexao().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
comandoSQL.setString(1, os.getServico());
comandoSQL.setFloat(2, os.getValor());
comandoSQL.setFloat(3, os.getValorTotal());
comandoSQL.executeUpdate();
ResultSet rs = comandoSQL.getGeneratedKeys();
rs.next();
int idServico = rs.getInt(1);
ArrayList<OrdemServico> ordemS = os.getOrdemS();
for (OrdemServico ordem : ordemS) {
ordem.setCod_servicoAberto(idServico);
cadastrarServico(ordem);
}
}
tenho que pegar os valores(servico,valor,valorTotal) de um jtable e salvar no banco...
queria saber se ta certo esse método...
desde ja agradeço!!
