Connection conn=null; PreparedStatement pstmt=null; ResultSet rs=null;是什么意思,是属性吗?
publicclassBaseDao{Connectionconn=null;PreparedStatementpstmt=null;ResultSetrs=null;p...
public class BaseDao {
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
private String driver="oracle.jdbc.driver.OracleDriver";
private String url="jdbc:oracle:thin:@localhost:1521:orcl";
private String username="gjh";
private String password="admin";
/**
* 连接数据库
* @return
*/
public Connection connection(){
try {
Class.forName(driver);
conn=DriverManager.getConnection(url,username,password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
} 展开
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
private String driver="oracle.jdbc.driver.OracleDriver";
private String url="jdbc:oracle:thin:@localhost:1521:orcl";
private String username="gjh";
private String password="admin";
/**
* 连接数据库
* @return
*/
public Connection connection(){
try {
Class.forName(driver);
conn=DriverManager.getConnection(url,username,password);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询