Amigos boa noite,
estou tentando fazer uns testes e adicionar alguns textos ao banco de dados MYSQL, porém está dando o seguinte erro:
HTTP Status 500 -
________________________________________
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
com.mysql.jdbc.Util.getInstance(Util.java:384)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113)
com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1364)
br.com.transligeiro.DAO.FuncionariosDAO.cadastraFuncionario(FuncionariosDAO.java:56)
br.com.transligeiro.action.FuncionariosAction.execute(FuncionariosAction.java:23)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
não sei o que fazer, pois sou iniciante e o erro não está tão claro pra mim, seguem o DAO e outras classes para verificarem.
funcionariosDAO
// CADASTRA O FUNCIONÁRIO COM ENDEREÇO E DADOS BANCÁRIOS
public void cadastraFuncionario(Funcionario funcionario) throws SQLException {
PreparedStatement stmt;
stmt = connection.prepareStatement("insert into funcionarios values(null,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
stmt.setString(1, funcionario.getNomeCompleto());
stmt.setString(2, funcionario.getFuncao());
stmt.setString(3, funcionario.getFiliacao1());
stmt.setString(4, funcionario.getFiliacao2());
stmt.setString(5, funcionario.getNaturalidade());
stmt.setString(6, funcionario.getGrauEscolaridade());
stmt.setString(7, funcionario.getDependentes());
stmt.setInt(8, funcionario.getIdadeDependentes());
stmt.setString(9, funcionario.getEstadoCivil());
stmt.setString(10, funcionario.getCtps());
stmt.setString(11, funcionario.getSerieCtps());
stmt.setString(12, funcionario.getPis());
stmt.setString(13, funcionario.getRg());
stmt.setString(14, funcionario.getCpf());
stmt.setString(15, funcionario.getTituloEleitor());
stmt.setString(16, funcionario.getZonaTituloEleitor());
stmt.setString(17, funcionario.getSecaoTituloeleitor());
stmt.setDate(18, new Date(funcionario.getDataNascimento().getTimeInMillis()));
stmt.setString(19, funcionario.getEmpregoAnterior());
stmt.setString(20, funcionario.getTelContato());
stmt.setString(21, funcionario.getCelContato());
stmt.setString(22, funcionario.getEmail());
stmt.setDate(23, new Date(funcionario.getDataAdmissao().getTimeInMillis()));
stmt.execute();
funcionariosAction
//CADASTRO DOS FUNCIONARIOS
@Action(value="cadastraFuncionario", results= {
@Result(name="ok", type="redirectAction", params= {"actionName", "preencheTela"})
})
public String execute() throws Exception {
new FuncionariosDAO().cadastraFuncionario(funcionario);
mensagemErro = "Funcionário cadastrado com sucesso!!";
return "ok";
}
e a página JSP
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Cadastro de Documentos</title>
</head>
<body>
<form id="cadastraFuncionario" name="cadastraFuncionario" method="post" action="cadastraFuncionario">
<table align="center" width="50%">
<tr>
<td>
<label>Nome Completo:</label></td>
<td>
<input type="text" size ="80" name="funcionario.nomeCompleto" id="funcionario.nomeCompleto"/>
</td>
<td>
<label>Função:</label></td>
<td>
<input type="text" name="funcionario.funcao" id="funcionario.funcao"/>
</td>
</tr>
<tr>
<td><label>Endereço:</label></td>
<td>
<input type="text" size ="80" name="funcionario.endereco.endereco" id="funcionario.endereco.endereco"/>
</td>
<td><label>Número:</label></td>
<td>
<input type="text" name="funcionario.endereco.numero" id="funcionario.endereco.numero"/>
</td>
</tr>
<tr>
<td><label>Bairro:</label></td>
<td>
<input type="text" size ="30" name="funcionario.endereco.bairro" id="funcionario.endereco.bairro"/>
</td>
<td><label>Cidade:</label></td>
<td>
<input type="text" name="funcionario.endereco.cidade" id="funcionario.endereco.cidade"/>
</td>
</tr>
<tr>
<td><label>UF:</label></td>
<td>
<input type="text" size ="30" name="funcionario.endereco.uf" id="funcionario.endereco.uf"/>
</td>
<td><label>CEP:</label></td>
<td>
<input type="text" name="funcionario.endereco.cep" id="funcionario.endereco.cep"/>
</td>
</tr>
<tr>
<td><label>Nome da mãe:</label></td>
<td>
<input type="text" size ="80" name="funcionario.filiacao1" id="funcionario.filiacao1"/>
</td>
</tr>
<tr>
<td><label>Nome do pai:</label></td>
<td>
<input type="text" size ="80" name="funcionario.filiacao2" id="funcionario.filiacao2"/>
</td>
<td><label>Naturalidade:</label></td>
<td>
<input type="text" name="funcionario.naturalidade" id="funcionario.naturalidade"/>
</td>
</tr>
<tr>
<td><label>Grau escolaridade:</label></td>
<td>
<input type="text" size ="80" name="funcionario.grauEscolaridade" id="funcionario.grauEscolaridade"/>
</td>
</tr>
<tr>
<td><label>Filhos?:</label></td>
<td>
<select name="funcionario.dependentes" id="funcionario.dependentes">
<option value="0">Selecionar</option>
<option>SIM</option>
<option>NÃO</option>
</select>
</td>
<td><label>Idade:</label></td>
<td>
<input type="text" name="funcionario.idadeDependentes" id="funcionario.idadeDependentes"/>
</td>
</tr>
<tr>
<td><label>Estado Civil:</label></td>
<td>
<select name="funcionario.estadoCivil" id="funcionario.estadoCivil">
<option value="0">Selecionar</option>
<option>CASADO(A)</option>
<option>SOLTEIRO(A)</option>
<option>DIVORCIADO(A)</option>
<option>VIÚVO(A)</option>
</select>
</td>
</tr>
<tr>
<td><label>CTPS:</label></td>
<td>
<input type="text" name="funcionario.ctps" id="funcionario.ctps"/>
</td>
<td><label>Série:</label></td>
<td>
<input type="text" name="funcionario.serieCtps" id="funcionario.serieCtps"/>
</td>
</tr>
<tr>
<td><label>PIS:</label></td>
<td>
<input type="text" name="funcionario.pis" id="funcionario.pis"/>
</td>
<td><label>RG:</label></td>
<td>
<input type="text" name="funcionario.rg" id="funcionario.rg"/>
</td>
<td><label>CPF:</label></td>
<td>
<input type="text" name="funcionario.cpf" id="funcionario.cpf"/>
</td>
</tr>
<tr>
<td><label>Título Eleitor:</label></td>
<td>
<input type="text" name="funcionario.tituloEleitor" id="funcionario.tituloEleitor"/>
</td>
<td><label>ZONA:</label></td>
<td>
<input type="text" name="funcionario.zonaTituloEleitor" id="funcionario.zonaTituloEleitor"/>
</td>
<td><label>SEÇÃO:</label></td>
<td>
<input type="text" name="funcionario.secaoTituloeleitor" id="funcionario.secaoTituloeleitor"/>
</td>
</tr>
<tr>
<td><label>Data Nascimento:</label></td>
<td>
<input type="text" name="funcionario.dataNascimento" id="funcionario.dataNascimento"/>
</td>
</tr>
<tr>
<td><label>Primeiro Emprego:</label></td>
<td>
<input type="radio" name="funcionario.empregoAnterior" id="funcionario.empregoAnterior" value="Sim">Sim</input><input type="radio" name="funcionario.empregoAnterior" id="funcionario.empregoAnterior" value="Não">Não</input>
</td>
</tr>
<tr>
<td><label>Tel Contato:</label></td>
<td>
<input type="text" name="funcionario.telContato" id="funcionario.telContato"/>
</td>
<td><label>Cel Contato:</label></td>
<td>
<input type="text" name="funcionario.celContato" id="funcionario.celContato"/>
</td>
</tr>
<tr>
<td><label>Data Admissão:</label></td>
<td>
<input type="text" name="funcionario.dataAdmissao" id="funcionario.dataAdmissao"/>
</td>
</tr>
<tr></tr>
<tr></tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Cadastrar"/></td>
</tr>
</table>
</form>
</body>
</html>
Agradeço a todos desde já