-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDBMS.java
More file actions
55 lines (47 loc) · 1.63 KB
/
DBMS.java
File metadata and controls
55 lines (47 loc) · 1.63 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
49
50
51
52
53
54
55
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dbms;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.DriverManager;
/**
*
* @author Admin
*/import java.sql.*;
public class DBMS {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Connection conn = null;
try{
String driverName = "oracle.jdbc.OracleDriver";
Class.forName(driverName);
String serverName = "LAPTOP-CAL2CB75";
String serverPort = "1522";
String sid = "XE";
String url = "jdbc:oracle:thin:@" + serverName +":" + serverPort + ":" + sid;
String username = "VARSHIL";
String password = "admin";
conn = DriverManager.getConnection(url, username, password);
System.out.println("Successful login");
}catch(Exception e){
System.out.println("Exception caught --> " + e);
}
try{
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("Select * from death_records");
while(rs.next()){
int no = rs.getInt(1);
String name = rs.getString(2);
System.out.println("no: "+no+" name: "+name);
}
}catch(Exception e){
e.printStackTrace();
}
}
}