G
gbman
Unregistered / Unconfirmed
GUEST, unregistred user!
client.java
import java.net.*;
import java.io.*;
public class client
{
public static void main(String[] args)
{
Socket clientSocket;
BufferedReader br1,br2;
PrintStream ps;
String username,passwords,email,homepage,moneys,inString;
try
{
clientSocket=new Socket("china-zzkdn8t9z.",8886);
br1=new BufferedReader(new InputStreamReader(System.in));
br2=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
ps=new PrintStream(clientSocket.getOutputStream());
System.out.print("请输入用户姓名(必输项,最多20个字符):");
username=br1.readLine();
ps.flush();
inString=br2.readLine();
System.out.println(inString);
System.out.print("请输入密码(必输项,最多20个字符):");
passwords=br1.readLine();
ps.println(passwords);
ps.flush();
inString=br2.readLine();
System.out.println(inString);
System.out.print("请输入电子邮件地址(必输项,最多30个字符):");
email=br1.readLine();
ps.println(email);
ps.flush();
inString=br2.readLine();
System.out.println(inString);
System.out.print("请输入个人主页(必输项,最多50个字符):");
homepage=br1.readLine();
ps.println(homepage);
ps.flush();
inString=br2.readLine();
System.out.println(inString);
System.out.print("请输入金额(必输项,只能是数字):");
moneys=br1.readLine();
ps.println(moneys);
ps.flush();
inString=br2.readLine();
System.out.println(inString);
br1.close();
br2.close();
ps.close();
clientSocket.close();
}catch(Exception e)
{
System.out.println(e);
}
}
}
server.java
import java.net.*;
import java.io.*;
import java.sql.*;
import com.microsoft.jdbc.sqlserver.SQLServerDriver;
import java.util.Properties;
public class server
{
public static void main(String[] args) throws Exception
{
ServerSocket serverSocket;
Socket clientSocket;
BufferedReader br;
PrintStream ps;
String username,passwords,email,homepage,moneys,outString,sql;
Properties p = new Properties();
p.put("databasename","userinfo");
p.put("user","liupeng");
p.put("password","");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://china-zzkdn8t9z.:8888",p);
Statement stmt=con.createStatement();
serverSocket=new ServerSocket(8886);
clientSocket=serverSocket.accept();
br=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
ps=new PrintStream(clientSocket.getOutputStream());
username=br.readLine();
outString="/t/t/t/t/t你输入的姓名是:"+username;
ps.print(outString);
ps.flush();
passwords=br.readLine();
outString="/t/t/t/t/t你输入的密码是:"+passwords;
ps.println(outString);
ps.flush();
email=br.readLine();
outString="/t/t/t/t/t你输入的邮件地址是:"+email;
ps.println(outString);
ps.flush();
homepage=br.readLine();
outString="/t/t/t/t/t你输入的主页是:"+homepage;
ps.println(outString);
ps.flush();
moneys=br.readLine();
outString="/t/t/t/t/t你输入的金额是:"+moneys;
ps.println(outString);
ps.flush();
sql="insert info userinfo values(/'"+username+"/',/'"+passwords+"/',/'"+email+"/',/'"+homepage+"/',sysdate,"+moneys+")";
int ret=stmt.executeUpdate(sql);
br.close();
ps.close();
stmt.close();
con.close();
}
}
import java.net.*;
import java.io.*;
public class client
{
public static void main(String[] args)
{
Socket clientSocket;
BufferedReader br1,br2;
PrintStream ps;
String username,passwords,email,homepage,moneys,inString;
try
{
clientSocket=new Socket("china-zzkdn8t9z.",8886);
br1=new BufferedReader(new InputStreamReader(System.in));
br2=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
ps=new PrintStream(clientSocket.getOutputStream());
System.out.print("请输入用户姓名(必输项,最多20个字符):");
username=br1.readLine();
ps.flush();
inString=br2.readLine();
System.out.println(inString);
System.out.print("请输入密码(必输项,最多20个字符):");
passwords=br1.readLine();
ps.println(passwords);
ps.flush();
inString=br2.readLine();
System.out.println(inString);
System.out.print("请输入电子邮件地址(必输项,最多30个字符):");
email=br1.readLine();
ps.println(email);
ps.flush();
inString=br2.readLine();
System.out.println(inString);
System.out.print("请输入个人主页(必输项,最多50个字符):");
homepage=br1.readLine();
ps.println(homepage);
ps.flush();
inString=br2.readLine();
System.out.println(inString);
System.out.print("请输入金额(必输项,只能是数字):");
moneys=br1.readLine();
ps.println(moneys);
ps.flush();
inString=br2.readLine();
System.out.println(inString);
br1.close();
br2.close();
ps.close();
clientSocket.close();
}catch(Exception e)
{
System.out.println(e);
}
}
}
server.java
import java.net.*;
import java.io.*;
import java.sql.*;
import com.microsoft.jdbc.sqlserver.SQLServerDriver;
import java.util.Properties;
public class server
{
public static void main(String[] args) throws Exception
{
ServerSocket serverSocket;
Socket clientSocket;
BufferedReader br;
PrintStream ps;
String username,passwords,email,homepage,moneys,outString,sql;
Properties p = new Properties();
p.put("databasename","userinfo");
p.put("user","liupeng");
p.put("password","");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://china-zzkdn8t9z.:8888",p);
Statement stmt=con.createStatement();
serverSocket=new ServerSocket(8886);
clientSocket=serverSocket.accept();
br=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
ps=new PrintStream(clientSocket.getOutputStream());
username=br.readLine();
outString="/t/t/t/t/t你输入的姓名是:"+username;
ps.print(outString);
ps.flush();
passwords=br.readLine();
outString="/t/t/t/t/t你输入的密码是:"+passwords;
ps.println(outString);
ps.flush();
email=br.readLine();
outString="/t/t/t/t/t你输入的邮件地址是:"+email;
ps.println(outString);
ps.flush();
homepage=br.readLine();
outString="/t/t/t/t/t你输入的主页是:"+homepage;
ps.println(outString);
ps.flush();
moneys=br.readLine();
outString="/t/t/t/t/t你输入的金额是:"+moneys;
ps.println(outString);
ps.flush();
sql="insert info userinfo values(/'"+username+"/',/'"+passwords+"/',/'"+email+"/',/'"+homepage+"/',sysdate,"+moneys+")";
int ret=stmt.executeUpdate(sql);
br.close();
ps.close();
stmt.close();
con.close();
}
}