WEB开发网
开发学院软件开发Java java程序操作MySQL数据库 阅读

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;
 }
 public void CloseDataBase() {// 关闭数据库
 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;
 public people() {
 }
 public people(String uid, String name, String 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;
 }
 public String getUid() {
 return uid;
 }
 public void setUid(String uid) {
 this.uid = uid;
 }
 public String getName() {
 return name;
 }
 public void setName(String name) {
 this.name = name;
 }
 public String getBanji() {
 return banji;
 }
 public void setBanji(String banji) {
 this.banji = banji;
 }
 public int getScore() {
 return score;
 }
 public void setScore(int 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')";
 database_manage db_obj = new database_manage();
 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);

上一页  1 2 3 4  下一页

Tags:java 程序 操作

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接