• 大小: 9.37MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-06
  • 语言: Java
  • 标签: Java  

资源简介

用JSP、Servlet和JavaBean开发一个简单的留言系统。。

资源截图

代码片段和文件信息

package Demo;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

/**
 * 数据库操作类
 * @author 
 *
 */

public class baseDao {

    //数据库地址“jdbc:mysql://服务器域名:端口号/数据库名称”
    private String url = “jdbc:mysql://127.0.0.1:3306/chartdemo?useUnicode=true&characterEncoding=utf-8“;
    //用户名
    private String user = “root“;
    //用户密码
    private String pwd = “123456“;
    //数据库链接对象
    private java.sql.Connection conn;
    //数据库命令执行对象
    private PreparedStatement pstmt;
    //数据库返回结果
    private java.sql.ResultSet rs;
    
    //静态代码块
    static{
        //1、加载驱动
        try {
            Class.forName(“com.mysql.jdbc.Driver“);
        } catch (ClassNotFoundException e) {
            
            e.printStackTrace();
        }
    }
    
    //2、创建连接
    private void getConnection(){
        if(conn == null){
            try {
                conn = DriverManager.getConnection(url user pwd);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    
    //执行读操作方法
    public java.sql.ResultSet executeQuery(String query
                    Listject> params){
        getConnection();
        try {
            //3、创建命令执行对象
            pstmt = conn.prepareStatement(query);
            //4、执行
            if(params!=null && params.size()>0){
                for(int i=0;i                    pstmt.setobject(i+1 params.get(i));
                }
            }
            rs = pstmt.executeQuery();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return rs;
    }
    
    //执行写操作方法
    public int executeUpdate(String query
            Listject> params){
        int result = 0;
        getConnection();
        try {
            //3、创建命令执行对象
            pstmt = conn.prepareStatement(query);
            //4、执行
            if(params!=null && params.size()>0){
                for(int i=0;i                    pstmt.setobject(i+1 params.get(i));
                }
            }
            //5、处理结果
            result = pstmt.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            //6、释放资源
            this.close();
        }
        return result;
    }

    
    //关闭资源
    public void close(){        
            try {
                if(rs!=null){
                    rs.close();
                    rs = null;
                }
                if(pstmt!=null){
                    pstmt.close();
                    pstmt = null;
                }
                if(conn!=null){
                    conn.close();
                    conn = null;
                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件          0  2019-03-13 14:03  ChartDemo\.metadata\.lock

     文件     584986  2019-03-14 23:54  ChartDemo\.metadata\.log

     文件        399  2019-03-14 22:36  ChartDemo\.metadata\.plugins\com.genuitec.eclipse.desktop\dialog_settings.xml

     文件       1591  2019-03-15 00:22  ChartDemo\.metadata\.plugins\com.genuitec.eclipse.sqlexplorer\ConnectionProfiles.xml

     文件      17339  2019-03-15 00:22  ChartDemo\.metadata\.plugins\com.genuitec.eclipse.sqlexplorer\SQLDrivers.xml

     文件       3594  2019-03-14 22:36  ChartDemo\.metadata\.plugins\com.genuitec.eclipse.templates\velocity.log

     文件          0  2019-03-14 10:24  ChartDemo\.metadata\.plugins\com.genuitec.org.hibernate.eclipse\hibernate-tools.log

     文件         48  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\log\log.ctrl

     文件    1048576  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\log\log1.dat

     文件         48  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\log\logmirror.ctrl

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c10.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c101.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c111.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c121.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c130.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c141.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c150.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c161.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c171.dat

     文件      32768  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c180.dat

     文件      16384  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c191.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c1a1.dat

     文件      16384  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c1b1.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c1c0.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c1d1.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c1e0.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c1f1.dat

     文件      28672  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c20.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c200.dat

     文件       8192  2019-03-14 13:21  ChartDemo\.metadata\.plugins\org.eclipse.birt.report.data.oda.jdbc.dbprofile.sampledb\db\BirtSample\seg0\c211.dat

............此处省略993个文件信息

评论

共有 条评论