druid的使用

//获取连接
        String url = "jdbc:mysql:///xuexi";
        String user = "root";
        String passwd = "123321";
        Connection cnt = DriverManager.getConnection(url, user, passwd);
        //加载配置文件
        Properties prop = new Properties();
        prop.load(new FileInputStream("java/src/druid.properties"));
        //获取连接池
        DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
        Connection connection = dataSource.getConnection();
        System.out.println(connection);

druid下载连接: https://repo1.maven.org/maven2/com/alibaba/druid/

您可能还喜欢...