Js Debug:
Loading...

Category Archives: Collect  | - 查看最近留言- |   | - 详细分类查看TAGS - |   | - 打开LRC-19LINE - |

jQuery记录:UI使用和cookie插件.

继续阅读…Continue Reading » » »

Posted 27 十月 2008 19.§Collect评论 (0)± Tags: +  

Oracle11G集群测试记录.

还是因为工作经验太浅,虽然工作中每天都要用到ORACLE,不过集群还是第一次接触(包括11G也是第一次用),10G和11G在使用方面没有什么太大区别,主要还是记录下这次集群的测试和使用JDBC链接ORACLE RAC的连接串配置。

这次的客户是双机访问操作数据库,一台实例名是orcl1,一台是orcl2。访问数据库服务名是orcl,之前我也搜了些资料,最后的想法是写了一个测试程序来测试JDBC链接ORACLE RAC的连接串。代码如下:

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
 
public class RacTest {
 
	/**
	 * 测试RAC
	 * 
	 */
	public static void main(String[] args) throws ClassNotFoundException {
 
		String url;
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
 
		Properties conProps = new Properties();
 
		conProps.put("user", "sys");
		conProps.put("password", "sys");
		conProps.put("internal_logon", "sysdba");
 
		// String username = "sys";
		// String password = "oracle";
 
		url = "jdbc:oracle:thin:@(description= (ADDRESS_LIST =";
		url += "(address=(protocol=tcp)(host=10.37.27.111)(port=1521))";
		url += "(address=(protocol=tcp)(host=10.37.27.112)(port=1521))";
		url += "(load_balance=yes))";
		url += "(connect_data =";
		url += "(server = dedicated)";
		url += "(service_name=orcl)";
		url += "(failover_mode =";
		url += "(type=session)";
		url += "(method=basic)";
		url += "(retries=5)";
		url += "(delay=15))";
		url += " ))";
 
		String sql = "select * from v$instance";
 
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
			conn = DriverManager.getConnection(url, conProps);
			// conn = DriverManager.getConnection(url, username, password);
			stmt = conn.createStatement();
			rs = stmt.executeQuery(sql);
			if (rs.next()) {
				System.out.print(rs.getString("INSTANCE_NAME"));
			}
			rs.close();
			rs = null;
			stmt.close();
			stmt = null;
			conn.close();
			conn = null;
		} catch (SQLException ex) {
			ex.printStackTrace();
		} finally {
 
			if (rs != null) {
				try {
					rs.close();
 
					rs = null;
				} catch (Exception ex) {
					ex.printStackTrace();
				}
			}
			if (stmt != null) {
				try {
					stmt.close();
					stmt = null;
				} catch (Exception ex) {
					ex.printStackTrace();
				}
			}
			if (conn != null) {
				try {
					conn.close();
					conn = null;
				} catch (SQLException ex) {
					ex.printStackTrace();
				}
			}
 
		}
 
	}
 
}
Posted 19 九月 2008 19.§Collect评论 (0)± Tags: