📄 serversql.java~16~
字号:
package new3;
import java.net.*;
import java.io.*;
import java.sql.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ServerSql {
public static String str="wroing";
public ServerSql() {
}
public static void main(String [] args)throws Exception{
String yn="wroing";
ServerSocket ss=new ServerSocket(4001);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception ce){
System.out.println("Classnull"+ce);
}
while(true){
Socket s = ss.accept();
BufferedReader b = new BufferedReader(new InputStreamReader(s.
getInputStream()));
String username = b.readLine();
String password = b.readLine();
String address = b.readLine();
try {
Connection con = DriverManager.getConnection("jdbc:odbc:test");
Statement stam = con.createStatement();
ResultSet rs = stam.executeQuery("select * from 天国人员资料");
while (rs.next()) {
if (username.equals(rs.getString(1)) &&
password.equals(rs.getString(2))) {
yn = "right";
str=yn;
PrintStream p = new PrintStream(s.getOutputStream());
p.println(yn);
break;
}
else
yn="wroing";
}
if(str.equals("right")){
break;
}
//Socket s1 = new Socket(address, 4001);
s.close();
//s1.close();
rs.close();
stam.close();
con.close();
} catch (Exception ee) {
System.out.println("sql:"+ee);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -