LibraryDAO.java
上传用户:ycdfsj258
上传日期:2022-08-04
资源大小:1094k
文件大小:2k
源码类别:

图形图象

开发平台:

Java

  1. package com.dao;
  2. import com.core.ConnDB;
  3. import java.sql.*;
  4. import com.actionForm.LibraryForm;
  5. /**
  6.  * <p>Title: LibraryManage</p>
  7.  *
  8.  * <p>Description: </p>
  9.  *
  10.  * <p>Copyright: Copyright (c) 2006</p>
  11.  *
  12.  * <p>Company:mr </p>
  13.  *
  14.  * @author:wgh
  15.  */
  16. public class LibraryDAO {
  17.     ConnDB conn=null;
  18.     public LibraryDAO() {
  19.         conn=new ConnDB();
  20.     }
  21.     public LibraryForm query(){
  22.         LibraryForm libraryForm1=null;
  23.         String sql = "select * from tb_library where id=1";
  24.         ResultSet rs =conn.executeQuery(sql);
  25.         try {
  26.             while (rs.next()) {
  27.                 libraryForm1 = new LibraryForm();
  28.                 libraryForm1.setId(Integer.valueOf(rs.getString(1)));
  29.                 libraryForm1.setLibraryname(rs.getString(2));
  30.                 libraryForm1.setCurator(rs.getString(3));
  31.                 libraryForm1.setTel(rs.getString(4));
  32.                 libraryForm1.setAddress(rs.getString(5));
  33.                 libraryForm1.setEmail(rs.getString(6));
  34.                 libraryForm1.setUrl(rs.getString(7));
  35.                 libraryForm1.setCreateDate(rs.getString(8));
  36.                 libraryForm1.setIntroduce(rs.getString(9));
  37.             }
  38.         } catch (Exception ex) {
  39.         }
  40.         conn.close();
  41.         return libraryForm1;
  42.     }
  43.     public int update(LibraryForm libraryForm){
  44.         String sql="UPDATE tb_library SET libraryname='"+libraryForm.getLibraryname()+"',curator='"+libraryForm.getCurator()+"',tel='"+libraryForm.getTel()+"',address='"+libraryForm.getAddress()+"',email='"+libraryForm.getEmail()+"',url='"+libraryForm.getUrl()+"',createDate='"+libraryForm.getCreateDate()+"',introduce='"+libraryForm.getIntroduce()+"' where id=1";
  45.         int ret=conn.executeUpdate(sql);
  46.         System.out.println("修改图书馆信息时的SQL:"+sql);
  47.         conn.close();
  48.         return ret;
  49.     }
  50. }