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

资源简介

一个完整的java web项目 包括sqlserver2005数据库

资源截图

代码片段和文件信息

package s2jsp.bysj.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class baseDao {    
    public final static String DRIVER = “com.microsoft.jdbc.sqlserver.SQLServerDriver“;                 // 数据库驱动
    public final static String URL    = “jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=company“;   // url
    public final static String DBNAME = “sa“;                                                           // 数据库用户名
    public final static String DBPASS = “120010“;                                                           // 数据库密码
    
    /**
     * 得到数据库连接
     * @throws ClassNotFoundException
     * @throws SQLException
     * @return 数据库连接
     */
    public Connection getConn() throws ClassNotFoundException SQLException{
        Class.forName(DRIVER);                                                    //注册驱动
        Connection conn = DriverManager.getConnection(URLDBNAMEDBPASS);        //获得数据库连接
        return conn ;                                                            //返回连接
    }
    
    /**
     * 释放资源
     * @param conn 数据库连接
     * @param pstmt PreparedStatement对象
     * @param rs 结果集
     */
    public void closeAll( Connection conn PreparedStatement pstmt ResultSet rs ) {
        /*  如果rs不空,关闭rs  */
        if(rs != null){
            try { rs.close();} catch (SQLException e) {e.printStackTrace();}
        }
        /*  如果pstmt不空,关闭pstmt  */
        if(pstmt != null){
            try { pstmt.close();} catch (SQLException e) {e.printStackTrace();}
        }
        /*  如果conn不空,关闭conn  */
        if(conn != null){
            try { conn.close();} catch (SQLException e) {e.printStackTrace();}
        }
    }
    
    /**
     * 执行SQL语句,可以进行增、删、改的操作,不能执行查询
     * @param sql  预编译的 SQL 语句
     * @param param  预编译的 SQL 语句中的‘?’参数的字符串数组
     * @return 影响的条数
     */
    public int executeSQL(String preparedSqlString[] param) {
        Connection        conn  = null;
        PreparedStatement pstmt = null;
        int               num   = 0;
        
        /*  处理SQL执行SQL  */
        try {
            conn = getConn();                              // 得到数据库连接
            pstmt = conn.prepareStatement(preparedSql);    // 得到PreparedStatement对象
            if( param != null ) {
                for( int i = 0; i < param.length; i++ ) {
                    pstmt.setString(i+1 param[i]);         // 为预编译sql设置参数
                }
            }
            num = pstmt.executeUpdate();                    // 执行SQL语句
        } catch (ClassNotFoundException e) {
            e.printStackTrace();                            // 处理ClassNotFoundException异常
        } catch (SQLException e) {
            e.printStackTrace();                            // 处理SQLException异常
        } finally {
            closeAll(connpstmtnull);                     // 释放

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

     文件        490  2007-10-31 14:45  company\company\.classpath

     文件        294  2007-10-04 12:26  company\company\.mymetadata

     文件       1225  2007-10-01 10:17  company\company\.project

     文件        127  2007-10-06 22:50  company\company\.settings\org.eclipse.core.resources.prefs

     文件       3221  2007-10-31 16:17  company\company\src\s2jsp\bysj\dao\baseDao.java

     文件       2506  2007-10-31 13:46  company\company\src\s2jsp\bysj\dao\MessageDao.java

     文件       4555  2007-10-07 13:37  company\company\src\s2jsp\bysj\dao\NewsDao.java

     文件       5022  2007-10-10 11:59  company\company\src\s2jsp\bysj\dao\ProductDao.java

     文件       1347  2007-10-08 13:27  company\company\src\s2jsp\bysj\dao\RevertDao.java

     文件       2981  2007-10-31 15:30  company\company\src\s2jsp\bysj\dao\UserDao.java

     文件       1456  2007-10-05 09:28  company\company\src\s2jsp\bysj\entity\Message.java

     文件        992  2007-10-01 09:20  company\company\src\s2jsp\bysj\entity\News.java

     文件       1961  2007-10-01 16:35  company\company\src\s2jsp\bysj\entity\Product.java

     文件       1368  2007-10-05 13:34  company\company\src\s2jsp\bysj\entity\Revert.java

     文件        984  2007-10-02 09:22  company\company\src\s2jsp\bysj\entity\Users.java

     文件       2244  2007-10-10 15:09  company\company\WebRoot\about.jsp

     文件       2345  2007-10-12 15:13  company\company\WebRoot\admin\addManager.jsp

     文件       2492  2007-10-31 13:38  company\company\WebRoot\admin\addNews.jsp

     文件       4441  2007-10-31 14:33  company\company\WebRoot\admin\addProduct.jsp

     文件        942  2007-10-10 17:24  company\company\WebRoot\admin\adminLoginManage.jsp

     文件        124  2007-10-10 16:50  company\company\WebRoot\admin\adminOut.jsp

     文件        270  2007-10-10 13:25  company\company\WebRoot\admin\checkSession.jsp

     文件       1341  2007-10-10 08:35  company\company\WebRoot\admin\index.jsp

     文件       5095  2007-10-08 14:34  company\company\WebRoot\admin\left.jsp

     文件       1797  2007-10-11 09:38  company\company\WebRoot\admin\manageNews.jsp

     文件       2732  2007-10-10 08:35  company\company\WebRoot\admin\manageProduct.jsp

     文件        226  2007-10-07 17:11  company\company\WebRoot\admin\right.jsp

     文件       1803  2007-10-10 08:35  company\company\WebRoot\admin\showUserList.jsp

     文件       4379  2007-10-11 09:26  company\company\WebRoot\admin\updateProduct.jsp

     文件       2621  2007-10-10 15:00  company\company\WebRoot\after.jsp

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

评论

共有 条评论