汪星人 发表于 2014-4-8 20:48

学生通讯录系统项目源码

package s2.jsp.zhangxiao.dao;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.sql.SQLException;

public class AddressBase {

private static final String DRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String URL="jdbc:sqlserver://localhost:1433;DataBaseName=addressDB";
private static final String DBNAME="sa";
private static final String DBPASS="1234";


public Connection getConnection(){
      Connection con=null;
      try {
                Class.forName(DRIVER);
                con=DriverManager.getConnection(URL, DBNAME, DBPASS);
      } catch (ClassNotFoundException e) {
                System.out.println("驱动异常");
                e.printStackTrace();
      } catch (SQLException e) {
      System.out.println("数据库异常");
                e.printStackTrace();
      }
      return con;
         
}
public void closeAll(Connection con,PreparedStatement past,ResultSet rs){
          try {
                rs.close();
      } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
      }
          try {
                past.close();
      } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
      }
          try {
                con.close();
      } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
      }
}
public int update(String sql,String[]getValues){
      int i=0;
      Connection con=null;
      PreparedStatement past=null;
      ResultSet rs=null;
      con=getConnection();
      try {
                past=con.prepareStatement(sql);
                if (getValues!=null) {
                        for (int j = 0; j < getValues.length; j++) {
                              past.setString(j+1, getValues);
                        }
                }
                i=past.executeUpdate();
      } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
      }
      return i;
         
}
}
package s2.jsp.zhangxiao.dao;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.sql.SQLException;

public class AddressBase {

private static final String DRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String URL="jdbc:sqlserver://localhost:1433;DataBaseName=addressDB";
private static final String DBNAME="sa";
private static final String DBPASS="1234";


public Connection getConnection(){
      Connection con=null;
      try {
                Class.forName(DRIVER);
                con=DriverManager.getConnection(URL, DBNAME, DBPASS);
      } catch (ClassNotFoundException e) {
                System.out.println("驱动异常");
                e.printStackTrace();
      } catch (SQLException e) {
      System.out.println("数据库异常");
                e.printStackTrace();
      }
      return con;
         
}
public void closeAll(Connection con,PreparedStatement past,ResultSet rs){
          try {
                rs.close();
      } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
      }
          try {
                past.close();
      } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
      }
          try {
                con.close();
      } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
      }
}
public int update(String sql,String[]getValues){
      int i=0;
      Connection con=null;
      PreparedStatement past=null;
      ResultSet rs=null;
      con=getConnection();
      try {
                past=con.prepareStatement(sql);
                if (getValues!=null) {
                        for (int j = 0; j < getValues.length; j++) {
                              past.setString(j+1, getValues);
                        }
                }
                i=past.executeUpdate();
      } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
      }
      return i;
         
}
}

源代码下载地址 :点击下载


汪星人 发表于 2014-4-8 20:51

package s2.jsp.zhangxiao.entity;
/**
* 实体类
* @author Administrator
*
*/
public class Address {
//        id, contactor, address, phone, email
        private int id;
        private String contactor;
        private String address;
        private String phone;
        private String email;
        /**
       * 构造函数
       * @param address 地址
       * @param contactor 联系人
       * @param email邮箱
       * @param id编号
       * @param phone 电话
       */
        public Address(String address, String contactor, String email, int id,
                        String phone) {
                super();
                this.address = address;
                this.contactor = contactor;
                this.email = email;
                this.id = id;
                this.phone = phone;
        }
        public Address() {
                super();
        }
        public int getId() {
                return id;
        }
        public void setId(int id) {
                this.id = id;
        }
        public String getContactor() {
                return contactor;
        }
        public void setContactor(String contactor) {
                this.contactor = contactor;
        }
        public String getAddress() {
                return address;
        }
        public void setAddress(String address) {
                this.address = address;
        }
        public String getPhone() {
                return phone;
        }
        public void setPhone(String phone) {
                this.phone = phone;
        }
        public String getEmail() {
                return email;
        }
        public void setEmail(String email) {
                this.email = email;
        }
       
}


javaWeb12 发表于 2014-4-12 15:30

学习了                        谢谢

是时候了 发表于 2014-12-26 14:59

谢谢楼主分享

阿轰 发表于 2015-5-15 23:15

看看,学学

阿轰 发表于 2015-5-15 23:16

话说楼主哪里来的代码,都是自己实现的吗

java宫城大师 发表于 2016-3-17 21:41


下来,学习一下。谢谢:victory:

hilivivi 发表于 2016-4-2 15:59

支持下!!!!!!:lol

小星星520 发表于 2016-4-19 17:13

挺好的,通讯录的设计方法都学会了,唉,自己又提高一点点,萌萌的!

贝斯特 发表于 2016-5-5 13:44

感谢 分享
页: [1] 2
查看完整版本: 学生通讯录系统项目源码