1 2 package org.objectweb.rmijdbc; 3 4 14 15 import java.sql.*; 16 import java.net.InetAddress ; 17 import java.security.*; 18 22 public class SSLClient { 23 24 public static void main(String args[]) { 25 try { 26 27 Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); 31 32 Class.forName("org.objectweb.rmijdbc.Driver").newInstance(); 36 37 String url = "jdbc:odbc:newtest"; 40 41 44 String portSpec = ""; 45 if(args.length > 0) { 46 Integer.parseInt(args[0]); portSpec = new String (":" + args[0]); 48 } 49 50 String rmiHost = new String ( 51 "//" + InetAddress.getLocalHost().getHostName() + portSpec); 52 53 56 String jurl = "jdbc:rmi:" + rmiHost + "/" + url; 57 System.out.println("SSLClient:" + jurl); 58 Connection c = DriverManager.getConnection(jurl); 59 60 Statement st = c.createStatement(); 61 ResultSet rs = st.executeQuery("select * from tb_names"); 62 63 ResultSetMetaData md = rs.getMetaData(); 64 while(rs.next()) { 65 System.out.print("\nTUPLE: | "); 66 for(int i=1; i<= md.getColumnCount(); i++) { 67 System.out.print(rs.getString(i) + " | "); 68 } 69 } 70 71 rs.close(); 72 73 } catch(Exception e) { 74 e.printStackTrace(); 75 } 76 } 77 78 }; 79 80 | Popular Tags |