Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 2 12 13 import java.sql.*; 14 import java.net.InetAddress ; 15 import java.security.*; 16 20 public class SSLClient { 21 22 public static void main(String args[]) { 23 try { 24 25 Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); 29 30 Class.forName("org.objectweb.rmijdbc.Driver").newInstance(); 34 35 String url = "jdbc:odbc:newtest"; 38 39 42 String portSpec = ""; 43 if(args.length > 0) { 44 Integer.parseInt(args[0]); portSpec = new String (":" + args[0]); 46 } 47 48 String rmiHost = new String ( 49 "//" + InetAddress.getLocalHost().getHostName() + portSpec); 50 51 54 String jurl = "jdbc:rmi:" + rmiHost + "/" + url; 55 System.out.println("SSLClient:" + jurl); 56 Connection c = DriverManager.getConnection(jurl); 57 58 Statement st = c.createStatement(); 59 ResultSet rs = st.executeQuery("select * from tb_names"); 60 61 ResultSetMetaData md = rs.getMetaData(); 62 while(rs.next()) { 63 System.out.print("\nTUPLE: | "); 64 for(int i=1; i<= md.getColumnCount(); i++) { 65 System.out.print(rs.getString(i) + " | "); 66 } 67 } 68 69 rs.close(); 70 71 } catch(Exception e) { 72 e.printStackTrace(); 73 } 74 } 75 76 }; 77 78
| Popular Tags
|