-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcars_data.java
More file actions
76 lines (70 loc) · 2.67 KB
/
Copy pathcars_data.java
File metadata and controls
76 lines (70 loc) · 2.67 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package car;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
/**
*
* @author Ammad
*/
public class cars_data {
public void show_vehicle() throws SQLException{
String query="Select * from vehicle";
Statement st=connection.connection.createStatement();
// ResultSet rs=st.executeQuery(query);
st.execute(query);
ResultSet re=st.getResultSet();
if(re!=null){
while(re.next()){
System.out.println("Car No for Order: "+re.getString(9));
System.out.println("Car: "+re.getString(1));
System.out.println("Price: "+re.getString(2));
System.out.println("Colour: "+re.getString(3));
System.out.println("Model: "+re.getString(4));
System.out.println("engine: "+re.getString(5));
System.out.println("power: "+re.getString(6));
System.out.println("priston: "+re.getString(7));
System.out.println("fuel: "+re.getString(8));
System.out.println("-------------------\n");
}
}
}
public void vehicle_ids() throws SQLException, IOException{
System.out.print("For Order a car, You need to enter car number: ");
Scanner input=new Scanner(System.in);
int order_action= input.nextInt();
String query="Select vehicle_id from vehicle";
Statement st=connection.connection.createStatement();
// ResultSet rs=st.executeQuery(query);
st.execute(query);
ResultSet re=st.getResultSet();
if(re!=null){
java.util.ArrayList alRowData = new java.util.ArrayList();
while(re.next()){
java.sql.ResultSetMetaData rsmd = re.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
for(int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex ++){
alRowData.add(re.getObject(columnIndex));
}
}
for(int i=0; i<alRowData.size(); i++){
if(order_action==(int)alRowData.get(i)){
order order=new order();
if(order.addOrder((int)alRowData.get(i), customer.id)==true)
{
System.out.println("Your Order Has been Placed");
}
else{
System.out.println("Car Number is not Correct");
}
}
}
}
}
}