EmployeeInfoBean.java~1~
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:2k
源码类别:
Java编程
开发平台:
Java
- package humanresource;
- import java.sql.*;
- public class EmployeeInfoBean {
- private String name, address, phone;
- private int id;
- private Connection conn;
- public void setName(String input){
- name = input;
- }
- public String getName(){
- return name;
- }
- public void setAddress(String input){
- address = input;
- }
- public String getAddress(){
- return address;
- }
- public void setPhone(String input){
- phone = input;
- }
- public String getPhone(){
- return phone;
- }
- public void setId(int input){
- id = input;
- }
- public int getId(){
- return id;
- }
- public Connection coninit(){
- try {
- Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
- conn= DriverManager.getConnection(
- "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=HumanResourcesDB;User=sa;Password=sa");
- }
- catch (SQLException ex) {
- }
- catch (ClassNotFoundException ex) {
- }
- return conn;
- }
- public void updateDatabase(Connection conn){
- try{
- String sql = "UPDATE EMPLOYEEINFO SET " +
- "NAME=?, ADDRESS=?, PHONE=? WHERE ID=?";
- PreparedStatement statement = conn.prepareStatement(sql);
- statement.setString(1, name);
- statement.setString(2, address);
- statement.setString(3, phone);
- statement.setInt(4, id);
- statement.executeQuery();
- }
- catch (Exception e) {}
- }
- public static Vector queryCompanyPolicies(){
- EmployeeInfoBean beanObj=new EmployeeInfoBean();
- Connection conQuery=beanObj.coninit();
- Statement statement = conQuery.createStatement();
- String sql = "SELECT * FROM BENEFITINFO";
- ResultSet rs = statement.executeQuery(sql);
- while (rs.next()){
- }
- }
- }