• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

updation of database

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to update the table emp_details. I had written a html form for
taking the input from the user, a jsp file for forwarding the request to a bean and a bean for updating a record of the emp_details table. When i test them in the server no error is coming. But the database is not updating.Here is the bean . Is the sql query written for updation is not correct.If yes then how should i write this query.
package bean;
import java.sql.*;
public class EmployeeInfoBean{
private String employeename,temporaryaddress,permanentaddress,emailaddress;
private int employeeno,departmentid,designationid,telephoneno,skillsetid;

public void setEmployeename(String input)
{
employeename=input;
}
public String getEmployeename()
{
return employeename;
}
public void setTemporaryaddress(String input)
{
temporaryaddress=input;
}
public String getTemporaryaddress()
{
return temporaryaddress;
}
public void setPermanentaddress(String input)
{
permanentaddress=input;
}
public String getPermanentaddress()
{
return permanentaddress;
}
public void setEmailaddress(String input)
{
emailaddress=input;
}
public String getEmailaddress()
{
return emailaddress;
}
public void setTelephoneno(int input)
{
telephoneno=input;
}
public int getTelephoneno()
{
return telephoneno;
}
public void setEmployeeno(int input)
{
employeeno=input;
}
public int getEmployeeno()
{
return employeeno;
}
public void setDepartmentid(int input)
{
departmentid=input;
}
public int getDepartmentid()
{
return departmentid;
}
public void setDesignationid(int input)
{
designationid=input;
}
public int getDesignationid()
{
return designationid;
}
public void setSkillsetid(int input)
{
skillsetid=input;
}
public int getSkillsetid()
{
return skillsetid;
}
public void updateDatabase(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn=
DriverManager.getConnection("jdbc dbc:employee1","","");
String sql ="UPDATE emp_details SET" + "employeename=?,temporaryaddress=?, permanentaddress=?,emailaddress=?, telephoneno=?, departmentid=?, designationid=?, skillsetid=? where employeeno=?";

PreparedStatement statement=conn.prepareStatement(sql);
statement.setInt(1, employeeno);
statement.setString(2, employeename);
statement.setString(3, temporaryaddress);
statement.setString(4, permanentaddress);
statement.setInt(5, telephoneno);
statement.setString(6, emailaddress);
statement.setInt(7, skillsetid);
statement.setInt(8, departmentid);
statement.setInt(9, designationid);


statement.executeQuery();

}
catch (Exception e){}
}
}
 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you might want to make sure you either commit the update or set autocommit to true.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since this is more about the JDBC/SQL than JSP, I'm moving this to the JDBC forum.
bear
 
reply
    Bookmark Topic Watch Topic
  • New Topic