-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataBase.java
More file actions
31 lines (25 loc) · 847 Bytes
/
DataBase.java
File metadata and controls
31 lines (25 loc) · 847 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
30
31
package chandana;
import java.sql.*;
public class DataBase {
public static void main(String[] args) {
try{
Class.forName("C:\\Users\\student\\Downloads");
System.out.println("Driver loaded successfully");
Connection con=DriverManager.getConnection("jdbc:mysql:"
+ "//localhost:3306/student","root","root@123");
System.out.println("Connection established sucessfully"+con);
Statement stmt=con.createStatement();
stmt.executeUpdate("insert into student (Name, USN, Sem) "
+ "values ('Kennedy','4VV21CS001',3)");
ResultSet rs=stmt.executeQuery("select * from student");
System.out.println("Name \tUSN \t\tSem");
while(rs.next())
System.out.println(rs.getString(1)+"\t"+
rs.getString(2)+"\t"+rs.getInt(3));
con.close();
}
catch(Exception e) {
System.out.println(e);
}
}
}