-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPharmacyManagement.java
51 lines (39 loc) · 1.36 KB
/
PharmacyManagement.java
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
import java.sql.*;
import java.util.*;
class PharmacyManagement {
static String db_url = "jdbc:mysql://localhost:3306/miniproject";
static String user = "root";
static String pass = "namMaha@123";
public static void insert(String email, String name, String address, String phNo, int age, String gender) throws SQLException {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("Connecting to database");
Connection con = DriverManager.getConnection(db_url, user, pass);
Statement stmt;
stmt = con.createStatement();
// Inserting data using SQL query
String sql1 = "insert into customer(email, name, address, phNo, age, gender)" + "values(?,?,?,?,?,?)";
System.out.println("Prepared");
PreparedStatement pst = con.prepareStatement(sql1);
pst.setString(1, email);
pst.setString(2, name);
pst.setString(3, address);
pst.setString(4, phNo);
pst.setInt(5,age);
pst.setString(6, gender);
pst.execute();
System.out.println("Executed");
con.close();
}catch(Exception ex){
}
}
public static void main(String args[]) throws Exception {
try {
new Login();
//
// insert("[email protected]", "Namita Mahamuni", "KV, Pune", "9970857677", 21, "F");
} catch (Exception ex) {
System.out.println(ex);
}
}
}