⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbconnection.java

📁 jsp+javabean+servlet案例
💻 JAVA
字号:
package db;
import java.util.ResourceBundle;
import java.sql.*;
import com.mchange.v2.c3p0.*;
import java.beans.*;

public class DBConnection {

    public static Connection getConnecton()
    {
        Connection conn = null;
        ResourceBundle res = ResourceBundle.getBundle("db");
        String driver = res.getString("driver");
        String url = res.getString("url");
        String username = res.getString("username");
        String password = res.getString("password");
        ComboPooledDataSource cd = new ComboPooledDataSource();
        try {
            cd.setDriverClass(driver);
            cd.setJdbcUrl(url);
            cd.setUser(username);
            cd.setPassword(password);
            cd.setMaxPoolSize(100);
            cd.setMinPoolSize(5);
            cd.setMaxIdleTime(10000);
            conn = cd.getConnection();
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (PropertyVetoException ex) {
            ex.printStackTrace();
        }
       
        return conn;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -