删除无用文件
This commit is contained in:
parent
298a2eaf87
commit
37d4834ad2
@ -1,48 +0,0 @@
|
||||
package com.example.springdemo.utils;
|
||||
|
||||
import com.example.springdemo.config.DataBaseProperties;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
@Component
|
||||
public class DataBaseUtil {
|
||||
@Resource
|
||||
DataBaseProperties dataBaseProperties;
|
||||
// Connect to database
|
||||
private final String connectionUrl =
|
||||
dataBaseProperties.getUrl() +
|
||||
dataBaseProperties.getUsername() +
|
||||
dataBaseProperties.getPassword();
|
||||
|
||||
public Connection getConnection() {
|
||||
Connection connection = null;
|
||||
try {
|
||||
// Code here.
|
||||
connection = DriverManager.getConnection(connectionUrl);
|
||||
}
|
||||
// Handle any errors that may have occurred.
|
||||
catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
//释放资源
|
||||
public void close(Connection conn, Statement st, ResultSet rs) {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
if (st != null) {
|
||||
st.close();
|
||||
}
|
||||
if (conn != null) {
|
||||
conn.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user