Java Reference
In-Depth Information
tableList.add( new DBTableRecord(rs.getLong("ID"),
rs.getLong("IDDataBase"), rs.getString("Name"),
rs.getString("Description"), rs.getString("Key"),
rs.getString("Label")));
rs.close(); stmt.close(); con.close();
} catch (Exception e) { e.printStackTrace();}
}
// returns an iterator of the list of thematic databases
public static Iterator getDBListIterator() {
return dbList.iterator();
}
// returns the list of tables in database "dbName"
public static Iterator getTableListIterator(String name){
ArrayList selectedTableInfo # new ArrayList();
long idDataBase # 0;
Iterator iterator # dbList.iterator();
while (iterator.hasNext()) {
DBListRecord dbRecord # (DBListRecord) iterator.next();
if (dbRecord.name.equals(name)) {
idDataBase # dbRecord.id;
break ;
}
}
iterator # tableList.iterator();
while (iterator.hasNext()) {
DBTableRecord tableRecord #
(DBTableRecord) iterator.next();
if (tableRecord.idDataBase ## idDataBase)
selectedTableInfo.add(tableRecord);
}
return selectedTableInfo.iterator();
}
public static DBValueRecord getRecord(String dbInfo[],
String keyValue) {
try {
// Load the jdbc-odbc bridge driver
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
String dbName # "jdbc:odbc:" ! dbInfo[0];
Connection con # DriverManager.getConnection(dbName);
Statement st # con.createStatement ();
// Extract the record related to the selected key
String query # "SELECT * FROM " ! dbInfo[1] !
" WHERE (" ! dbInfo[2] !
" # " ! keyValue ! ')';
ResultSet rs # st.executeQuery (query);
// parses the record
Search WWH ::




Custom Search