Hello, Im trying to insert data in my mysql server with a JSP and a Bean with an example I found in the internet, Im very new to all this but this error I get its really strange.
I created a table contacto (contact) in the mysql server,
create table contacto (numero int,
                                       nombre varchar (20),
                                       apellido varchar(20),
                                       Telefono int,
                                        Email varchar(50)
)
I made the bean acording to the example and I made a form so I can Input the data and the job of the bean would be to save this info in the database. But the problem is that I got an Error
 
 
javax.servlet.ServletException: DB.contacto.setapellido(Ljava/lang/String;)V
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
	org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.insertar_jsp:85)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

causa raĆ­z

java.lang.NoSuchMethodError: DB.contacto.setapellido(Ljava/lang/String;)V
	org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.insertar_jsp:59)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
so I decided to take out all the logic of the "apellido" field in the 
database and I took it out of the form and from the JSP file and guess what it 
Worked so I put all the "apellido" stuffs back with extra care of no making any mistakes 
this time, Idouble checked it with the other fields because hey they work but guess what
the error showed up again and I dont really know what the problem is, all I know its something related
to the get statement. 
Hope You can Help me
Thanks on Advance
Claudio Veas
Please Excuse my english 
Add FUN to your email - CLICK HERE!

Attachment: insertar.jsp
Description: unknown/unknown

package DB;

import java.sql.*;
import java.io.*;

public class contacto {

   private String dbURL = "jdbc:mysql://localhost:3306/test?user=jonas&password=jonas";
   private String dbDriver = "com.mysql.jdbc.Driver";
   private Connection dbCon;
   
   String Numero =null;
   String Nombre = null;
    String apellido =null;
   String Telefono = null;
   String Email = null;
  

   public contacto() {
      super();
   }

   public String getNumero() {
       return this.Numero;
   }
   public String getNombre() {
       return this.Nombre;
   }
   public String getapellido(){
   	return this.apellido;
   	}
   public String getTelefono() {
       return this.Telefono;
   }
public String getEmail() {
       return this.Email;
   }
   
   
   	
   public void setNumero(String Numero) {
       this.Numero = Numero;
   }

   public void setNombre(String Nombre) {
       this.Nombre = Nombre;

   }

public void setapellido(String apellido) {
       this.apellido = apellido;

   }

    public void setTelefono(String Telefono) {
       this.Telefono = Telefono;
   }
	public void setEmail(String Email) {
       this.Email = Email;
   }

   public void doInsert() throws ClassNotFoundException, SQLException {
      Class.forName(dbDriver);
      dbCon = DriverManager.getConnection(dbURL);
      Statement s = dbCon.createStatement();
      String sql = "INSERT INTO contactos values (" + this.Numero;
      sql = sql + ", '" + this.Nombre;
      sql = sql + "', " + this.Telefono + ", '" + this.Email;
      sql = sql + "')";
      int insertResult = s.executeUpdate(sql);
      dbCon.close();
   }
    
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to