当前位置:Gxlcms > 数据库问题 > 使用Druid连接数据库

使用Druid连接数据库

时间:2021-07-01 10:21:17 帮助过:37人阅读

static DataSource source; static { try { Properties properties = new Properties(); InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("Druid.properties"); properties.load(is); source = DruidDataSourceFactory.createDataSource(properties); } catch (Exception e) { e.printStackTrace(); } } public static Connection getConnection() throws SQLException { Connection connection = source.getConnection(); return connection; }

 

使用Druid连接数据库

标签:mysq   数据库连接   数据   use   static   导包   throws   actor   connect   

人气教程排行