-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15_02_2025_crud_test.java
More file actions
30 lines (25 loc) · 871 Bytes
/
Copy path15_02_2025_crud_test.java
File metadata and controls
30 lines (25 loc) · 871 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
27
28
29
30
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class CRUD_Test {
public static void main(String[] args){
CRUD_Test objTest = new CRUD_Test();
objTest.create_data("1","Shubham","shubham@gmail.com");
objTest.create_data("2","Shubham","shubhamraj@gmail.com");
}
public void create_data(String sl_no, String name, String email){
DB_Connection obj_DB_Connection = new DB_Connection();
Connection connection = obj_DB_Connection.connection();
PreparedStatement ps = null;
try{
ps = connection.prepareStatement( "insert into user(sl_no, name, email) values (?,?,?)");
ps.setString(1,sl_no);
ps.setString(2,name);
ps.setString(3,email);
System.out.println(ps);
ps.executeUpdate();
} catch (Exception e){
System.out.println(e);
}
}
}