码迷,mamicode.com
首页 > 其他好文 > 详细

2019.9.2课程设计情况

时间:2019-09-02 20:57:24      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:pre   mysq   服务器   cut   doget   小结   manage   nec   每日   

一、当天完成的任务

   今天开始搭服务器,我们使用eclipse配tomcat,然后Android studio来做客户端。今天先把tomcat给配置完了,然后eclipse中的tomcat遇到一些问题,出现了error,争取今天晚上解决。

技术图片

 

  服务器端的代码:Login

技术图片
package com.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LoginTest
 */
@WebServlet("/LoginTest")
public class Login extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Login() {
        super();
        // TODO Auto-generated constructor stub
    }
    public void init(ServletConfig config) throws ServletException {
        // TODO Auto-generated method stub
        super.init(config);
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        Connection con;
        Statement sql;
        String logname = request.getParameter("logname").trim();
        String password = request.getParameter("password").trim();
        String uri = "jdbc:mysql://localhost/MakeFriend";
        try {
            con = DriverManager.getConnection(uri,"root","201513010223");
            String condition = "select * from member where logname = ‘"+logname+"‘ and password = ‘"+password+"‘";
            sql = con.prepareStatement(condition);
            ResultSet rSet = sql.executeQuery(condition);
            if(rSet.next()) {
                out.println("login successfully!");
            }
            else {
                out.println("can not login!");
            }
            con.close();        
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}
技术图片

 

二、第二天的计划

   将tomcat和eclipse配置完成,将服务器搭建完成。

三、每日小结

1.当初J2EE学得忘得差不多了,现在搭服务器感觉很费劲。

2.感觉走进了死胡同,死在了服务器里。

2019.9.2课程设计情况

标签:pre   mysq   服务器   cut   doget   小结   manage   nec   每日   

原文地址:https://www.cnblogs.com/hj609/p/11448903.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!