-
Notifications
You must be signed in to change notification settings - Fork 206
/
Copy pathque1.java
32 lines (30 loc) · 974 Bytes
/
que1.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
public class SampleClass
{
public static void main(String args[]) throws SQLException
{
Connection myConn = null;
Statement myStmt = null;
ResultSet myRs = null;
try
{
myConn = DriverManager.getConnection("jdbc:mysql://localhost:3306/librarys", "root" , "");
myStmt = myConn.createStatement();
myRs = myStmt.executeQuery("select * from book");
while (myRs.next())
{
System.out.println(myRs.getString("Acc_no") + ", " + myRs.getString("Title") + ", " + myRs.getString("Author") + ", " + myRs.getString("Publisher")+ ", " +
myRs.getString("Edition"));
}
}
catch (Exception exc)
{
exc.printStackTrace();
}
finally
{
myRs.close();
myStmt.close();
myConn.close();
}
}
}