01: package org.dbbrowser;
02:
03: import java.sql.Connection;
04: import java.sql.Driver;
05: import java.sql.ResultSet;
06: import java.sql.Statement;
07: import java.util.Properties;
08:
09: public class JDBCSSL {
10:
11: /**
12: * @param args
13: */
14: public static void main(String[] args) {
15: // Register the Oracle JDBC driver
16: System.out.println("Registring the driver...");
17: Connection conn = null;
18:
19: try {
20: Class driverClass = Class.forName(
21: "oracle.jdbc.OracleDriver", true, JDBCSSL.class
22: .getClassLoader());
23: Driver driver = (Driver) driverClass.newInstance();
24: Properties props = new Properties();
25: //props.put("oracle.net.encryption_client", "REQUIRED");
26: props.put("oracle.net.encryption_types_client", "DES56C");
27: //props.put("oracle.net.crypto_checksum_client", "REQUIRED");
28: //props.put("oracle.net.crypto_checksum_types_client","MD5");
29: props.put("user", "xcs_charging");
30: props.put("password", "abcxyz");
31:
32: conn = driver.connect("jdbc:oracle:thin:@romeo:1521:movdb",
33: props);
34:
35: // Create a Statement
36: Statement stmt = conn.createStatement();
37:
38: // Select the ENAME column from the EMP table
39: ResultSet rset = stmt.executeQuery("select ENAME from EMP");
40:
41: // Iterate through the result and print the employee names
42: while (rset.next()) {
43: System.out.println(rset.getString(1));
44: }
45: conn.close();
46: } catch (Exception e) {
47: System.out.println(e.getMessage());
48: e.printStackTrace();
49: }
50:
51: }
52:
53: }
|