-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBus.java
More file actions
36 lines (29 loc) · 844 Bytes
/
Copy pathBus.java
File metadata and controls
36 lines (29 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package BusReservation;
import java.sql.*;
public class Bus {
int BusNo;
boolean Ac;
int capacity;
public static void displayBuses() throws SQLException
{
Connection con = DBConnection.getConnection();
Statement st = con.createStatement();
String Q = "Select * from bus";
ResultSet rs = st.executeQuery(Q);
while(rs.next())
{
System.out.print("Bus no: "+ rs.getInt(1)+"\n");
System.out.print("AC: "+rs.getBoolean(2)+"\n");
System.out.println("Capacity: "+rs.getInt(3)+"\n");
}
}
public static int getCapacity(int BusNo) throws SQLException
{
Connection con = DBConnection.getConnection();
Statement st = con.createStatement();
String Q = "select capacity from bus where "+BusNo;
ResultSet rs = st.executeQuery(Q);
rs.next();
return rs.getInt(1);
}
}