用Java修改数据,改变数据库。

来源:百度知道 编辑:UC知道 时间:2024/05/22 14:45:14
package test;

public class AddEmployee{
public static void main(String[] args) {
int insertE=0;
System.out.println("插入员工数据");
insertE=InsertEmployee("1001", "Tom", "2009/3/6", "男", "Developer");
System.out.println(insertE);
}

/*
* 插入员工信息方法
*/
public static int InsertEmployee(String Eno,String Ename,String Ebir,String Esex,String Eworktype){
int i=0;
try{
String sql="insert into Employee(Eno,Ename,Ebir,Esex,Eworktype) values('"+Eno+"','"+Ename+"','"+Ebir+"','"+Esex+"','"+Eworktype+"')";
System.out.println(sql);
i=DAO.executeUpdate(sql);
}catch(Exception e){
System.out.println(e.getMessage());
}
DAO.close();
return i;
}
}
该参数,1900/1/1 1001
修改员

String sql="update Employee set(Ename='"+Ename+"',Ebir='"+Ebir+"',Esex='"+Esex+"',Eworktype='"+Eworktype+"') where Eno = '"+Eno+"';
变一下sql就可以了,不知道我说明白没,不明白再Hi我一下!