-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.java
68 lines (66 loc) · 1.9 KB
/
server.java
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
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.net.*;
import java.io.*;
import static java.lang.System.out;
import java.sql.*;
import java.math.*;
public class server
{
public static void main(String args[])throws Exception
{
ServerSocket ss1 = new ServerSocket(9999);
System.out.println("server started..!");
Socket s1 = ss1.accept();
String msg,fname,toname;
ServerSocket ss2 = new ServerSocket(6666);
Socket s2 = ss2.accept();
BigInteger d=BigInteger.ONE,n=BigInteger.ONE,decmod=BigInteger.ONE,decprvt=BigInteger.ONE;
BufferedReader br1 = new BufferedReader(new InputStreamReader(s1.getInputStream()));
PrintWriter pw1 = new PrintWriter(s1.getOutputStream(),true);
String client1 = br1.readLine();
BufferedReader br2 = new BufferedReader(new InputStreamReader(s2.getInputStream()));
PrintWriter pw2 = new PrintWriter(s2.getOutputStream(),true);
String client2 = br2.readLine();
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","mymotog2O");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from keys");
while(true)
{
msg = br1.readLine();
out.println(msg);
fname = br1.readLine();
out.println(fname);
toname = br1.readLine();
while(rs.next())
{
String ln = rs.getString(1);
if(fname.equals(ln))
{
d = new BigInteger(rs.getString(3));
n = new BigInteger(rs.getString(4));
}
}
pw2.println(fname);
pw2.println(msg);
pw2.println(d);
pw2.println(n);
msg = br2.readLine();
fname = br2.readLine();
out.println(fname);
toname = br2.readLine();
while(rs.next())
{
String ln = rs.getString(1);
if(fname.equals(ln))
{
decprvt = new BigInteger(rs.getString(3));
decmod = new BigInteger(rs.getString(4));
}
}
pw1.println(fname);
pw1.println(msg);
pw1.println(decprvt);
pw1.println(decmod);
}
}
}