Java 几个对象详细汉语解释?
在包下创建类:BaseDao 代码如下:
protected Connection con = null;
protected PreparedStatement pst = null;
protected ResultSet rs = null;
protected String sql = null;
编写打开方法:
public void open(){
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","tiger","tiger");
} catch (Exception e) {
e.printStackTrace();
}
}
编写关闭方法:(倒着关闭)
public void close(){
try {
if (rs!=null) {
rs.close();
rs = null;
}
if (pst!=null) {
pst.close();
pst = null;
}
if (con!=null) {