Try {
String user = "ahcwtest ";
String Password = "ahcwtest ";
String driver = "oracle. JDBC. Driver. oracledriver ";
String url = "JDBC: oracle: thin: @ 192.168.71.17: 1521: orcl ";
String SQL = "select a from ";
Class. forname (driver). newinstance ();
Connection c = drivermanager. getconnection (URL, user, password );
Statement stmt = C. createstatement ();
Resultset rs = stmt.exe cutequery (SQL );
Databasemetadata dbmd = C. getmetadata ();
Resultset PK = dbmd. getprimarykeys (null, null, "");
While (Pk. Next ()){
System. Out. println ("Table ");
System. Out. println ("pktable_cat:" + PK. GetObject (1 ));
System. Out. println ("pktable_schem:" + PK. GetObject (2 ));
System. Out. println ("pktable_name:" + PK. GetObject (3 ));
System. Out. println ("column_name:" + PK. GetObject (4 ));
System. Out. println ("key_seq:" + PK. GetObject (5 ));
System. Out. println ("pk_name:" + PK. GetObject (6 ));
}
Resultset T = dbmd. getcatalogs ();
While (T. Next ()){
System. Out. println (T. getstring (0 ));
}
// While (Rs. Next ()){
// System. Out. println (Rs. getstring (1 ));
//}
} Catch (exception e ){
E. printstacktrace ();
}