方式1:正常获取
package TTest;
import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;
/**
* @className: JDBCUtils
* @description: 封装JDBC获取连接和释放连接操作
* @author: CCQ
* @date: 2021/9/26
**/
public class JDBCUtils {
static Connection getConnection(){
Connection connection =null;
InputStream resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream("jdbc.properties");
Properties properties = new Properties();
try {
properties.load(resourceAsStream);
} catch (IOException e) {
e.printStackTrace();
}
try {
connection = DriverManager.getConnection(properties.getProperty("url"),properties.getProperty("user"),properties.getProperty("password"));
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return connection;
}
static void closeConnection(Connection connection, Statement statement, ResultSet resultSet){
if (null!=connection){
try {
connection.close();
} catch (SQLException throwables) {
throwables.printStackTrace