-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteCourse.java
More file actions
26 lines (26 loc) · 807 Bytes
/
DeleteCourse.java
File metadata and controls
26 lines (26 loc) · 807 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
import java.sql.*;
import java.util.*;
public class DeleteCourse {
public void del(String pno) {
Scanner sc=new Scanner(System.in);
try {
String url="jdbc:mysql://localhost:3306/course";
String userName="root";
String password="Hobartkings7*";
Connection con=DriverManager.getConnection(url,userName,password);
Statement st=con.createStatement();
ViewCourse obj=new ViewCourse();
obj.view(pno);
System.out.println("Enter the course id to delete");
int n=sc.nextInt();
String query="delete from usersdetails where pno="+pno+" and c_id="+n;
st.executeUpdate(query);
System.out.println("Course is deleted from your account successfully!");
query="commit";
st.execute(query);
}
catch(Exception e) {
System.out.println(e);
}
}
}