-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertSQL.java
More file actions
111 lines (77 loc) · 3.58 KB
/
Copy pathInsertSQL.java
File metadata and controls
111 lines (77 loc) · 3.58 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import java.sql.*;
import java.util.Scanner;
public class InsertSQL{
Scanner sc = new Scanner(System.in);
private Connection conn;
public InsertSQL() throws SQLException{
//MUST UPDATE BELOW WITH YOUR CLASS LINK AND PASSWORD////////////////////
String url = "CLASS_LINK_HERE phpMyAdmin_SQL";
url += "PERSONAL_PASSWORD_FROM_CLASS";
//MUST UPDATE ABOVE WITH YOUR CLASS LINK AND PASSWORD/////////////////////
conn = DriverManager.getConnection(url);
}
public void insertMemento() throws SQLException{
System.out.println("Insert Row into Memento");
System.out.print("Enter the name: ");
String Name = sc.nextLine();
System.out.print("Enter the yield: ");
String yield = sc.nextLine();
System.out.print("Enter the LeaderID: ");
String LeaderID = sc.nextLine();
Statement stmt= conn.createStatement();
String update = "INSERT INTO Memento VALUES('"+Name+"', '"
+yield+"', "+LeaderID+")";
stmt.executeUpdate(update);
System.out.println("Insert Completed.");
}
public void insertBuilding() throws SQLException{
System.out.println("Insert Row into Building");
System.out.print("Enter the name: ");
String Name = sc.nextLine();
System.out.print("Enter the Attribute: ");
String Attribute = sc.nextLine();
System.out.print("Enter the yield: ");
String yield = sc.nextLine();
System.out.print("Enter the CivID: ");
String CivID = sc.nextLine();
Statement stmt= conn.createStatement();
String update = "INSERT INTO Building VALUES('"+Name+"', '"
+Attribute+"', '"+yield+"', "+CivID+")";
stmt.executeUpdate(update);
System.out.println("Insert Completed.");
}
public void insertCivilization() throws SQLException{
System.out.println("Insert Row into Civilization");
System.out.print("Enter the name: ");
String Name = sc.nextLine();
System.out.print("Enter the Attribute: ");
String Attribute = sc.nextLine();
System.out.print("Enter the Attribute2: ");
String Attribute2 = sc.nextLine();
System.out.print("Enter the yield: ");
String yield = sc.nextLine();
Statement stmt= conn.createStatement();
String update = "INSERT INTO Civilization (Name, Attribute, Attribute2, yield) VALUES('"
+Name+"', '"+Attribute+"', '"+Attribute2+"', '"+yield+"')";
stmt.executeUpdate(update);
System.out.println("Insert Completed.");
}
public void insertLeader() throws SQLException{
System.out.println("Insert Row into Leader");
System.out.print("Enter the name: ");
String Name = sc.nextLine();
System.out.print("Enter the Attribute: ");
String Attribute = sc.nextLine();
System.out.print("Enter the Attribute2: ");
String Attribute2 = sc.nextLine();
System.out.print("Enter the yield: ");
String yield = sc.nextLine();
System.out.print("Enter the yield2: ");
String yield2 = sc.nextLine();
Statement stmt= conn.createStatement();
String update = "INSERT INTO Leader (Name, Attribute, Attribute2, yield, yield2) VALUES('"
+Name+"', '"+Attribute+"', '"+Attribute2+"', '"+yield+"', '"+yield2+"')";
stmt.executeUpdate(update);
System.out.println("Insert Completed.");
}
}