开发者

database questions in sql

The following query is in SQL:

SELECT r.reservation_no, f.flight_no, r.departure_date,
       f.departure_time, f.duration
  FROM flights f, reservations r
 WHERE f.flight_no=r.flight_no AND r.customer_ssn="234567";

Print the results to the screen in table form.

I need to make it in such a way that it can be compatible with JDBC.

rs = stmt.executeQuery("SELECT r.reservation_no, f.flight_no, r.departure_date, f.departure_time, f.duration FROM flights f开发者_C百科, reservations r WHERE f.flight_no=r.flight_no AND r.customer_ssn="234567");
while ( rs.next() ) {
    **String capacity = rs.getString("??????"); -- what should I use here? as I have to take many values from the tables?**
    System.out.println(capacity);
}


String query = "SELECT r.reservation_no, f.flight_no, r.departure_date, f.departure_time, f.duration FROM flights f, reservations r WHERE f.flight_no=r.flight_no AND r.customer_ssn="?" ";

PreparedStatement ps = connection.prepareStatement(query);
ps.setString(1, customer_ssn);
result = ps.executeQuery();


If i have understood your question correctly, then in the place of ??? you can have either the column name or the column index number.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜