-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.java
More file actions
29 lines (24 loc) · 774 Bytes
/
Copy pathDatabase.java
File metadata and controls
29 lines (24 loc) · 774 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
import java.lang.*;
import java.sql.*;
class Database
{
public static void main(String arg[])
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc::mysql://localhost:3306/marvellous","root","root");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from student");
while(rs.next())
{
System.out.println(rs.getInt(1) + " "+ rs.getString(2) + " " + rs.getInt(3) + " " + rs.getString(4));
}
con.close();
}
catch(Exception obj)
{
System.out.println("Exception occured :"+obj);
}
}
}