-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy pathrecord.java
More file actions
21 lines (19 loc) · 748 Bytes
/
record.java
File metadata and controls
21 lines (19 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.company;
import java.sql.*;
class Main
{
public static void main(String[] args)
{
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/data?autoReconnect=true&useSSL=false","root","ashu");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from studentdetails");
System.out.println("No \t Name \t Age \t Place" );
while(rs.next())
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t\t"+rs.getInt(3)+"\t\t"+rs.getString(4));
}
catch(Exception e){
System.out.println(e);}
}
}