我有一个名为Database的类.
public class Database {
public Connection connect = null;
public Statement st = null;
public PreparedStatement ps = null;
public ResultSet rs = null;
public boolean connectDB() throws Exception {
try {
Class.forName("com.mysql.jdbc.Driver");
connect = DriverManager
.getConnection("jdbc:mysql://localhost/ots?"
+ "user=root&password=mongolia");
} catch (Exception e) {
System.out.println(e);
}
return true;
}
public void disconnectDB() {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (connect != null) {
connect.close();
}
} catch (Exception …Run Code Online (Sandbox Code Playgroud)