47e290cb78dc2e4f41f30d4cdbbaee0bb02377ed.svn-base
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package yxy.timer.tool;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.DataSource;
public class DBUtil
{
private static DataSource dataSource;
//获得连接
public static Connection getConnection(String datesource) throws SQLException
{
dataSource = (DataSource) SpringFactory.getObject(datesource);
return dataSource.getConnection();
}
//关闭数据库连接
public static void close(ResultSet rs,Statement st,Connection conn){
if(rs!=null){ try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}finally{
if(st!=null){
try {
st.close();
} catch (SQLException e) {
e.printStackTrace();
}finally{
if(conn!=null){
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
}
}
}