新人学习,大侠请进解答,谢谢!!
我先发表一段代码,有一段看的不是很懂,
01.import java.sql.Connection;
02.import java.sql.DriverManager;
03.import java.sql.ResultSet;
04.import
java.sql.SQLException;
05.import java.sql.Statement;
06.
07.
08.public class DBTools {
09.// 定义一个方法,用来得到一个"新的"连接对象
10.public static Connection getConnection()
11.{
12.Connection conn = null;
13.String driverName = "oracle.jdbc.driver.OracleDriver";
14.String url = "jdbc:oracle:thin:@localhost:1521:ora9i";
15.String userName = "scott";
16.String passWord = "tiger";
17.try {
18.Class.forName(driverName);
19.conn = DriverManager.getConnection(url,userName,passWord );
20.} catch (Exception e) {
21.// TODO Auto-generated catch block
22.e.printStackTrace();
23.}
24.return conn;
25.}
26.
27.
28.public static void closeConn(Connection conn)
29.{
30.try {
31.if(conn != null)
32.{
33.conn.close();
34.}
35.} catch (
SQLException e) {
36.// TODO Auto-generated catch block
37.e.printStackTrace();
38.}
39.}
40.
41.
42.public static void closeState(Statement state)
43.{
44.try {
45.if(state != null)
46.{
47.state.close();
48.}
49.} catch (SQLException e) {
50.// TODO Auto-generated catch block
51.e.printStackTrace();
52.}
53.}
54.
55.
56.public static void closeRs(ResultSet rs)
57.{
58.try {
59.if(rs != null)
60.{
61.rs.close();
62.}
63.} catch (SQLException e) {
64.// TODO Auto-generated catch block
65.e.printStackTrace();
66.}
67.}
68.}
69.
70.
71.
72.
73.
74.
75.import java.sql.ResultSet;
76.import java.sql.Statement;
77.import java.util.ArrayList;
78.
79.
80.import com.tianyitime.notebook.support.userPO.UserPO;
81.import com.tianyitime.notebook.support.util.DBTools;
82.
83.
84.
85.
86.public class UserDAO {
87.
88.
89.// 新增user
90.public void saveUserInfo(UserPO