Hi, everyone. I have some problems with getting the data from ResultSet after executeQuery statement in Java. Here is my code:
try {
Statement statement = connection.crea teStatement();
String query = "select CITY, SHORT_NAME from airports";
ResultSet rs = statement.execu teQuery(query);
Vector data = new Vector();
System.out.prin tln(rs);
while (rs.next()){
Vector row = new Vector();
for (int i = 1; i <= 2; i++) {
System.out.prin tln(rs.getStrin g(i));
row.add(rs.getS tring(i));
}
}
rs.close();
lstAirportlist. setListData(dat a);
} catch (SQLException ex) {
ex.printStackTr ace();
}
I'm connected to the database and can resolve column names by:
column.addEleme nt(rs.getMetaDa ta().getColumnN ame(i));
but ResultSet (rs) contains only column names and no data inside. In database i have 3 rows of data. When making select in SQL Workbench everything runs smooth but in code when i try to print rs (and the same when set a watch) i get:
org.firebirdsql .jdbc.FBResultS et@10d9151
and it contains only 2 column labels without data.
Using firebird-full.jar and Netbeans 5.5.
I would be really thankfully if someone can get me some tips how to handle with that.
Thanks in advance.
try {
Statement statement = connection.crea teStatement();
String query = "select CITY, SHORT_NAME from airports";
ResultSet rs = statement.execu teQuery(query);
Vector data = new Vector();
System.out.prin tln(rs);
while (rs.next()){
Vector row = new Vector();
for (int i = 1; i <= 2; i++) {
System.out.prin tln(rs.getStrin g(i));
row.add(rs.getS tring(i));
}
}
rs.close();
lstAirportlist. setListData(dat a);
} catch (SQLException ex) {
ex.printStackTr ace();
}
I'm connected to the database and can resolve column names by:
column.addEleme nt(rs.getMetaDa ta().getColumnN ame(i));
but ResultSet (rs) contains only column names and no data inside. In database i have 3 rows of data. When making select in SQL Workbench everything runs smooth but in code when i try to print rs (and the same when set a watch) i get:
org.firebirdsql .jdbc.FBResultS et@10d9151
and it contains only 2 column labels without data.
Using firebird-full.jar and Netbeans 5.5.
I would be really thankfully if someone can get me some tips how to handle with that.
Thanks in advance.