-
Notifications
You must be signed in to change notification settings - Fork 0
/
DB.java
66 lines (59 loc) · 1.69 KB
/
DB.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.sql.*;
public class DB
{
Connection con;
Statement stmt;
ResultSet rs;
public DB() throws Exception
{
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/library";
con = DriverManager.getConnection(url,"root","thakur");
stmt = con.createStatement();
}
public void update(String qry) throws Exception
{
stmt.executeUpdate(qry);
}
public ResultSet execute(String qry) throws Exception
{
rs=stmt.executeQuery(qry);
return rs;
}
public int getbookcatid() throws Exception
{
String qry = "select ifnull(max(bookcatid),0)max from tbbookcat";
rs = stmt.executeQuery(qry);
rs.next();
int n = rs.getInt("max");
n++;
return n;
}
public int bookid() throws Exception
{
String qry = "select ifnull(max(bookid),0)max from tbbook";
rs = stmt.executeQuery(qry);
rs.next();
int n = rs.getInt("max");
n++;
return n;
}
public int getissueid() throws Exception
{
String qry = "select ifnull(max(issueid),0)max from tbissue";
rs = stmt.executeQuery(qry);
rs.next();
int n = rs.getInt("max");
n++;
return n;
}
public int getfineid() throws Exception
{
String qry = "select ifnull(max(fineid),0)max from tbfine";
rs = stmt.executeQuery(qry);
rs.next();
int n = rs.getInt("max");
n++;
return n;
}
}