1 2 10 11 import java.sql.*; 12 import java.net.InetAddress ; 13 14 18 public class TestClient { 19 20 public static void main(String args[]) { 21 22 try { 23 24 Class.forName("org.objectweb.rmijdbc.Driver").newInstance(); 28 29 String url = "jdbc:idb:sample.prp"; 33 34 37 String portSpec = ""; 38 if(args.length > 0) { 39 Integer.parseInt(args[0]); portSpec = new String (":" + args[0]); 41 } 42 43 String rmiHost = new String ( 44 "//" + InetAddress.getLocalHost().getHostName() + portSpec); 45 46 49 String jurl = "jdbc:rmi:" + rmiHost + "/" + url; 50 System.out.println("TestClient:" + jurl); 51 Connection c = DriverManager.getConnection(jurl); 52 53 Statement st = c.createStatement(); 54 ResultSet rs = st.executeQuery("select * from import1"); 55 56 ResultSetMetaData md = rs.getMetaData(); 57 while(rs.next()) { 58 System.out.print("\nTUPLE: | "); 59 for(int i=1; i<= md.getColumnCount(); i++) { 60 System.out.print(rs.getString(i) + " | "); 61 } 62 } 63 64 rs.close(); 65 66 } catch(Exception e) { 67 e.printStackTrace(); 68 } 69 } 70 }; 71 72 | Popular Tags |