java程序操作MySQL数据库
2012-12-08 15:43:06 来源:WEB开发网核心提示:CloseDataBase();return num; } public void CloseDataBase() {// 关闭数据库try { conn.close();} catch (Exception end) { System.err.println("执行关闭Connection对象有错误:&qu
CloseDataBase();
return num;
return num;
}
public void CloseDataBase() {// 关闭数据库
try {
conn.close();
} catch (Exception end) {
System.err.println("执行关闭Connection对象有错误:" + end.getMessage());
System.out.print("执行执行关闭Connection对象有错误:有错误:" + end.getMessage()); // 输出到客户端
}
}
try {
conn.close();
} catch (Exception end) {
System.err.println("执行关闭Connection对象有错误:" + end.getMessage());
System.out.print("执行执行关闭Connection对象有错误:有错误:" + end.getMessage()); // 输出到客户端
}
}
}
class people {
private String uid;
private String name;
private String banji;
private int score;
private String uid;
private String name;
private String banji;
private int score;
public people() {
}
}
public people(String uid, String name, String banji) {
this.uid = uid;
this.name = name;
this.banji = banji;
}
this.uid = uid;
this.name = name;
this.banji = banji;
}
public people(String uid, String name, String banji, int score) {
this.uid = uid;
this.name = name;
this.banji = banji;
this.score = score;
}
this.uid = uid;
this.name = name;
this.banji = banji;
this.score = score;
}
public String getUid() {
return uid;
}
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
this.uid = uid;
}
public String getName() {
return name;
}
return name;
}
public void setName(String name) {
this.name = name;
}
this.name = name;
}
public String getBanji() {
return banji;
}
return banji;
}
public void setBanji(String banji) {
this.banji = banji;
}
this.banji = banji;
}
public int getScore() {
return score;
}
return score;
}
public void setScore(int score) {
this.score = score;
}
this.score = score;
}
}
public class manage {
private people[] people_array1;// 对象数组
public void add_people(String uid, String name) {
String sql = "insert people (uid,name) values ('" + uid + "','" + name
+ "')";// sql插入语句
// String sql2 = "insert people (uid,name) values ('uid001','tom')";
+ "')";// sql插入语句
// String sql2 = "insert people (uid,name) values ('uid001','tom')";
database_manage db_obj = new database_manage();
db_obj.update_database(sql);
}
db_obj.update_database(sql);
}
public void update_people(String uid, String name) {
String sql = "update people set name='" + name + "' where uid='" + uid
+ "'";
+ "'";
database_manage db_obj = new database_manage();
db_obj.update_database(sql);
}
public void delete_people(String uid) {
String sql = "delete from people where uid='" + uid + "'";
database_manage db_obj = new database_manage();
db_obj.update_database(sql);
更多精彩
赞助商链接