-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateSQL.java
More file actions
39 lines (30 loc) · 1.33 KB
/
Copy pathUpdateSQL.java
File metadata and controls
39 lines (30 loc) · 1.33 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
import java.sql.*;
import java.util.Scanner;
public class UpdateSQL{
Scanner sc = new Scanner(System.in);
private Connection conn;
public UpdateSQL() 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 updateRow() throws SQLException{
System.out.println("Updating row info");
System.out.print("Enter Table name that need to be update: ");
String Table = sc.nextLine();
System.out.print("Enter column name that needs to be update: ");
String Column = sc.nextLine();
System.out.print("Enter the updated information: ");
String Info = sc.nextLine();
System.out.print("Enter row 'name' that needs to be update: ");
String Row = sc.nextLine();
Statement stmt= conn.createStatement();
String update = "UPDATE "+Table+" SET "+Column+" = '"
+Info+"' WHERE Name = '"+Row+"';";
stmt.executeUpdate(update);
System.out.println("Updated Row Completed.");
System.out.println();
}
}