时间:2021-07-01 10:21:17 帮助过:35人阅读
static{
dataSource = new ComboPooledDataSource("mvcApp");
}
public static Connection getConnection() throws Exception
{
return dataSource.getConnection();
}
public static void releaseDB(ResultSet resultSet,Statement statement,Connection connection)
{
if(resultSet != null)
{
try {
resultSet.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(statement != null)
{
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(connection != null)
{
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
c3p0文档
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<named-config name="mvcApp">
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://localhost:3306/test</property>
<property name="user">root</property>
<property name="password">1111</property>
</named-config>
</c3p0-config>
JDBC链接数据库
标签:jdbc c3p0 外部文件