Fiz do jeito que alguns exemplos do Google me mostraram...mas não tá rolando...
Ele não encontra a Procedure.
Eu tenho que passar o nome dela no "MAIN"?
Ficou assim:
import java.sql.Connection;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import com.mysql.jdbc.CallableStatement;
/**
* @author Arthur.Gomes
*/
public class MarcacaoDAO extends DAOBase{
///Atributos estáticos dos Métodos principais//////
private static String INSERT = null;
public MarcacaoDAO() {
this(null);
}
public MarcacaoDAO(Connection connection) {
super(connection);
///Inserindo Dados nos Campos da Tabela//////
StringBuffer stringBuffer = new StringBuffer();
if(INSERT == null){
stringBuffer.delete(0, stringBuffer.length());
stringBuffer.append(" {call sp_MCC_RPT(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}");
INSERT = stringBuffer.toString();
}
}
////////MÉTODO UTILIZADO PARA INSERIR REGISTROS//////////////
public boolean inserir(MarcacaoVO marcacaoVO) throws SQLException{
CallableStatement callableStatement = null;
Connection con = null;
try{
con = super.getConnection();
callableStatement = (CallableStatement) con.prepareCall(INSERT);
int index = 1;
///Campos que serão preenchidos///
callableStatement.setInt(index++, marcacaoVO.getCodigoMarcacao());
callableStatement.setInt(index++, marcacaoVO.getEmpresa());
callableStatement.setInt(index++, marcacaoVO.getMatricula());
callableStatement.setString(index++,marcacaoVO.getStatusMarcacao());
callableStatement.setInt(index++,marcacaoVO.getMarcacaoViaCracha());
callableStatement.setDate(index++,utilDateTOsqlDate(marcacaoVO.getDataMarcacao()));
callableStatement.setTime(index++, utilDateTOsqlTime(marcacaoVO.getHoraMarcacao()));
callableStatement.setInt(index++, marcacaoVO.getEmpresaRelogio());
callableStatement.setInt(index++,marcacaoVO.getFilialRelogio());
callableStatement.setInt(index++,marcacaoVO.getCodigoMarcRelogio());
callableStatement.setString(index++,marcacaoVO.getStatusMarcacao());
callableStatement.setInt(index++,marcacaoVO.getCodTipoMarcacao());
callableStatement.setString(index++,marcacaoVO.getStatusTransmissao());
callableStatement.setString(index++,marcacaoVO.getMarcacaoEnv());
callableStatement.setString(index++,marcacaoVO.getMarcacaoErr());
callableStatement.setString(index++,marcacaoVO.getModoAutentica());
int retorno = callableStatement.executeUpdate();
callableStatement.getResultSet();
if(retorno > 0){
return true;
}else{
return false;
}
} finally {
close(null, callableStatement, con);
}
}
E o MAIN ficou dessa forma:
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
SimpleDateFormat sdf2 = new SimpleDateFormat("dd-MM-yyyy");
MarcacaoVO vo = new MarcacaoVO();
vo.setCodigoMarcacao(3);
vo.setEmpresa(7);
vo.setMatricula(2);
vo.setStatusMarcacao("W");
vo.setMarcacaoViaCracha(7);
try {
vo.setDataMarcacao(sdf2.parse("07-07-2008"));
vo.setHoraMarcacao(sdf.parse("07:30:00"));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
vo.setEmpresaRelogio(7);
vo.setFilialRelogio(7);
vo.setCodigoMarcRelogio(1);
vo.setStatusTipoMarcacao("w");
vo.setCodTipoMarcacao(1);
vo.setMarcacaoEnv("W");
vo.setMarcacaoErr("W");
vo.setStatusTransmissao("W");
vo.setModoAutentica("W");
MarcacaoDAO dao = new MarcacaoDAO();
try {
dao.inserir(vo);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Gravado com sucesso!!");
}
}
Enfim...o erro é de não localizar a Procedure...
Valeu gente.