学生通讯录系统项目源码
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;
}
}
源代码下载地址 :点击下载
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;
}
}
学习了 谢谢 谢谢楼主分享
看看,学学 话说楼主哪里来的代码,都是自己实现的吗
下来,学习一下。谢谢:victory: 支持下!!!!!!:lol 挺好的,通讯录的设计方法都学会了,唉,自己又提高一点点,萌萌的! 感谢 分享
页:
[1]
2