1 import java.sql.*;
2
3 public class OracleConn
4 {
5 Connection conn;
6 public OracleConn()
7 {
8 try
9 {
10 Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
11 String urlname = "jdbc:oracle:thin:@localhost:1521:hcm";
12 String user ="system";
13 String pw = "manager";
14 conn = DriverManager(urlname,user,pw).getConnection();
15 }
16 catch(Exception ep)
17 {
18 ep.printStackTrace();
19 conn = null;
20 }
21 }
22 public ResultSet getRS(String sql)
23 {
24 try
25 {
26 Statement stm = con.creatStatement();
27 ResultSet rs = stm.executeQuery(sql);
28 return rs;
29 }catch (Exception e)
30 {
31 e.printStackTrace();
32 return null;
33 }
34 }
oracle的连接,测试成功!
posted on 2007-02-06 16:50
-274°C 阅读(310)
评论(0) 编辑 收藏 所属分类:
JAVA