-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathques.java
More file actions
48 lines (28 loc) · 1.07 KB
/
ques.java
File metadata and controls
48 lines (28 loc) · 1.07 KB
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
import jdbc.*;
import java.io.BufferedReader;
import java.io.IOException;
import.sql.*;
public class ques{
publuc static void main("String[] args throws IOException")
connection con= null;
Statement stat=null;
Resultset res= null;
try{
con=DriverManager.getConnection("jdbc:mysql://localhost:8080/practicalDB","root","Shalini31");
stat=con.createStatement();
res=stat.executeQuery("select * from book");
while(res.next()){
System.out.println("Acession No\t" + "Title\t"+"Author\t"+"Edition\t"+"Publisher\t");
}
bufferedReader br=new Buffered(new InputStreamReader(System.in));
int n = Interger.parseInt(br.readline());
String query ="select * from book wher AccessionNO ="+ n;
res = stat.executeQuery(query);
while(res.next()){
System.out.println("Acession No\t" + "Title\t"+"Author\t"+"Edition\t"+"Publisher\t");
System.out.println(res.getString("AccessionNo") +res.getString("Title")+res.getString("Author")+res.getString("Edition")+res.getString("Publisher");
}
}
catch(Exception exc){
exc.printStackTrace();
}