我也是初学,给你参考一下
tomcat服务器端:
public class LoginOrRegServlet extends HttpServlet { //登录和注册服务器
private static final long serialVersionUID = 1L;
private static final String Driver = "com.mysql.jdbc.Driver"; //mysql驱动
private static final String ConnectUrl = "jdbc:MySQL://localhost:3306/itosystem";//连接数据库的URL
private String User = "root"; //登录数据库的用户名和密码
private String Password = "num12369";
@Override
protected void service(HttpServletRequest request,HttpServletResponse response) {String connUserName; //取得请求中的用户名和密码
String connPassword;
String Action; //判断请求中是登录还是注册
boolean isNull = false; //根据用户名查询数据库是否查到
Connection conn = null;
DataOutputStream dos = null;
Statement statement = null;
ResultSet rs = null;
connUserName &#