Olá carsos , amigos…
Gostaria q algum colega mais interado em Java me ajudem se possível… Já li um monte de respostas… parecidas com o meu caso, porém, não se enquandram e também não entendi bem aonde colocar a solução… em q trecho do código pra ser mais exato…
Se alguem puder dar uma olha no código… ai vai a parte q + me interessa…
//arquivo:--> Documento.java
package modelo;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Documento {
private int controle;
private Date entrada;
private String numero_doc;
private Date data_doc;
private String origem;
private String descricao;
private Date saida;
private String destino;
public String getIncluir(){
String s="";
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(Exception e){
return ("Driver não carregado.");
}
try{
Connection conexao=DriverManager.getConnection(
"jdbc:mysql://localhost:3306/meubanco","root","1111");
PreparedStatement sql=conexao.prepareStatement(
"insert into tbdocs(controle, entrada, data_doc, numero_doc, origem, descricao, destino, saida) values (?,?,?,?,?,?,?,?)");
sql.setInt(1, controle);
sql.setString (2, entrada.toString());
sql.setDate(3, data_doc);
sql.setString(4, numero_doc);
sql.setString(5, origem);
sql.setString(6, descricao);
sql.setDate(7, saida);
sql.setString(8, destino);
sql.executeUpdate();
s=" Documento Incluído com sucesso!!! ";
}catch(SQLException e){
s=e.getMessage();
}
return s;
}
...
-------------------------------------------------------------------------------------------------------------
//arquivo:--> incluir1.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Incluir</title>
</head>
<body>
<%@include file="menu.jsp"%>
<form action="incluir2.jsp"method="post">
Controle:<input name="controle"><br>
Entrada:<input name="entrada"><br>
Data_doc:<input name="data_doc"><br>
Numero:<input name="numero_doc"><br>
Origem:<input name="origem"><br>
Descrição:<input name="descricao"><br>
Saida:<input name="saida"><br>
Destino:<input name="destino"><br>
<input type="submit" value="Enviar">
<input type="reset" value="Limpar">
</form>
</body>
</html>
-------------------------------------------------------------------------------------------------------
//arquivo:--> incluir2.jsp
<jsp:useBean id="doc" class="modelo.Documento"></jsp:useBean>
<jsp:setProperty property="*" name="doc" />
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="modelo.Documento"%>
<%@include file="menu.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Inclusão de Dados...</title>
</head>
<body>
<jsp:getProperty name="doc" property="incluir" />
</body>
</html>
-------------------------------------------------------------------------------------------------------
ERROR:
Unable to convert string "2008-03-28" to class "java.sql.Date" for attribute "saida": Property Editor not registered with the PropertyEditorManager
at org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:887)
-------
Agardo resposta e agradesço desde já a todos…
:lol: