Hello,
I have the following problem but first the situation :
I have succesfully connected to an existing Ms-Access database and retrieved the resultset of three colomns.
One colomn of the resultset is "name" which I'd like to place in a Jlist.
To the right of my Jlist are some Jtextfields which are the other fields of my database and are also in my resultset (the other columns).
Here's what I want, when I click on a name in the Jlist I want the Jtextfields to change also with their corresponding values...
Here's the code of what I already have.
Somebody already gave me some help and told me to use Vectors.
But it's not really working.
try{
// create a statement handler
Statement sqlStatement = databaseConnection.createStatement();
// create a sql-string
String sql = "SELECT NAME,TYPE,LENGTH,DESCRIPT
FROM VELD ORDER BY NAME";
ResultSet results = sqlStatement.executeQuery(sql);
ResultSetMetaData rsmd = results.getMetaData();
int totCol = rsmd.getColumnCount();
// here are the two vectors one for the columns
one for the rows but how do I USE THEM ???
while (results.next())
{
Vector newCol = new Vector();
for (int i =1 ; i <= totCol; i++ )
{
newCol.addElement(results.getObject(i));
rows.addElement(newCol);
}
}
// close connection
databaseConnection.close();
System.out.println("the connection is closed !");
} catch (SQLException sqle) {
System.err.println(sqle);
}
}
Can anybody help me ??
Thanks
Kristof