1 package metadata; 2 3 import dinamica.*; 4 import java.sql.*; 5 6 17 public class GetPKInfo extends GenericTransaction 18 { 19 20 23 public int service(Recordset inputs) throws Throwable 24 { 25 26 int rc = super.service(inputs); 27 28 Recordset rsinfo = new Recordset(); 29 rsinfo.append("table", java.sql.Types.VARCHAR); 30 31 String types[] = {"TABLE"}; 32 33 DatabaseMetaData md = getConnection().getMetaData(); 34 ResultSet tables = md.getTables(null, inputs.getString("schema"), "%", types); 35 Recordset rs = new Recordset(tables); 36 tables.close(); 37 38 while (rs.next()) 39 { 40 String table = rs.getString("table_name"); 41 ResultSet pk = md.getPrimaryKeys(null, inputs.getString("schema"), table); 42 if (!pk.next()) 43 { 44 rsinfo.addNew(); 45 rsinfo.setValue("table", table); 46 } 47 pk.close(); 48 } 49 50 publish("tables", rsinfo); 51 52 return rc; 53 54 } 55 56 } 57 | Popular Tags |