大家帮我看看这个DBConnection怎么样
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
public class DBConnection {
static Connection conn=null;
static {
try {
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost/manage?" +
"user=root&password=root");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static Connection getConnection(){
return conn;
}
public static Statement getStatement(){
Statement stmt=null;
try {
stmt = getConnection().createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
return stmt;
}
public static PreparedStatement getPreparedStatement(String str){
PreparedStatement pstmt=null;
try {
pstmt = getConnection().prepareStatement(str);
} catch (SQLException e) {
e.printStackTrace();
}
return pstmt;
}
}