-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathDButil.java
More file actions
36 lines (34 loc) · 970 Bytes
/
Copy pathDButil.java
File metadata and controls
36 lines (34 loc) · 970 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
31
32
33
34
35
36
package coom.mca.demo;
import java.sql.*;
public class DButil {
static Connection con=null;
static PreparedStatement pst=null;
static ResultSet rs=null;
public static Connection getConn(){
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","kattu27");
}
catch(Exception e) {
System.out.println(e);
}
return con;
}
public static ResultSet getData()throws Exception{
con=getConn();
pst=con.prepareStatement("select * from users");
rs=pst.executeQuery();
return rs;
}
public static int addData(UserBean b)throws Exception{
int i=0;
con=getConn();
pst=con.prepareStatement("insert into users values(?,?,?,?)");
pst.setString(1,b.getName());
pst.setString(2, b.getPassword());
pst.setInt(3, b.getAge());
pst.setInt(4,b.getPhone());
i=pst.executeUpdate();
return i;
}
}