-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathfetch.java
More file actions
32 lines (31 loc) · 817 Bytes
/
fetch.java
File metadata and controls
32 lines (31 loc) · 817 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
32
import java.io.*;
import java.sql.*;
class fetch
{
public static void main(String args[])
{
try{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter SID");
String SID=br.readLine();
Class.forName("oracle.jdbc.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","123456");
Statement stmt=con.createStatement();
String q1="select * from student where SID='"+SID+"'";
ResultSet rs=stmt.executeQuery(q1);
if(rs.next())
{
System.out.println("SID="+rs.getString(1));
System.out.println("NAME="+rs.getString(2));
System.out.println("COLLEGE="+rs.getString(3));
System.out.println("PHONE="+rs.getString(4));
}
else
System.out.println("No Data Found");
con.close();
}
catch(Exception e)
{
}
}
}