• 河北金力集团公文流转系统


    package com.Util;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Scanner;
    import org.apache.catalina.User;
    public class DBUtil {
     public static final String connectionURL="jdbc:mysql://localhost:3306/new_schem1?useUnicode=true&characterEncoding=GB18030&useSSL=false&serverTimezone=GMT&allowPublicKeyRetrieval=true";
     public static final String username="root";
     public static final String password="123456";
     static Connection connection;
     static ResultSet rSet;
     static PreparedStatement ps;
     static Scanner scanner=new Scanner(System.in);
     
     public static Connection getConnection()
     {
      try {
       Class.forName("com.mysql.cj.jdbc.Driver");
       //Class.forName("com.mysql.cj.jdbc.Driver");
       return DriverManager.getConnection(connectionURL, username, password);
      } catch (Exception e) {
       // TODO: handle exception
       System.out.println("数据库连接失败");
       e.printStackTrace();
      }
      return null;
     } //数据库连接
     
     public static boolean getUsername()     //遍历获取数据库中的内容
     {
      try {
       Connection connection2 = getConnection();
       connection=connection2;
          ps= connection.prepareStatement("select * from new_schem1.jinliwenjian");
       rSet=ps.executeQuery();//执行sql语句
       //System.out.println("yhjyuki");
       while(rSet.next())
       {
         System.out.println(rSet.getString(1)+" "+rSet.getString(2)+" "+rSet.getString(3)+" "+rSet.getString(4)+" "+rSet.getString(5)+" "+rSet.getString(6));
       }
      }
      catch(SQLException e)
      {
       e.printStackTrace();
      }
      return false;
     }
     
     
     
     public static boolean dengluchaxun(bean.User user)
     { 
      
      try {
           connection=getConnection();
           String sql="select * from jinliwenjian where username = '"+user.getUsername()+"' and password = '"+user.getPassword()+"' and status != 0";
           ps= connection.prepareStatement(sql);
           rSet=ps.executeQuery();
           if(rSet.next()==false)
            {
            System.out.println("用户名或密码错误");
            return false;
            }
           else
            {
            System.out.println("用户名及密码正确");
            return true;
            }
      } catch (Exception e) {
       // TODO: handle exception
      }
      return false;
      
     }
     public static void main(String[] args) {
      // TODO 自动生成的方法存根
      getUsername();
      
     
     }
    }
     
     
     
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>金立文件流转系统(办公室)</title>
    <script>
    function check()
       {
        
         var username=document.getElementById("text1").value;
            var  n=/^[a-zA-Z0-9_]{4,10}$/;
            if(!n.test(username)){
            document.getElementById("pwspan1").innerHTML="请输入正确的用户名!";
            }else{
             document.getElementById("pwspan1").innerHTML="";
            }
           }
        function check1()
        {
            var password1=document.getElementById("text2").value;
            var  n=/^[a-zA-Z0-9_]{4,10}$/;
            if(!n.test(password1)){
            document.getElementById("pwspan2").innerHTML="请输入正确的密码!";
            }else{
             document.getElementById("pwspan2").innerHTML="";
            }
           
          }
          </script>
    </head>
    <body>
       <style>
       .div1{
        background-color:lightseagreen;
                    1000px;
                    height:100px;
                    margin:auto;
                    padding-top:50px;
                    font-family: "微软雅黑";
                    font-size:40px;
       }
       .div2{
        background: yellow;
        500px;
        height:250px;
        margin: auto;
        padding-top:80px;
       }
       .div3{
        background-color:yellow;
        300px;
        height:170px;
       }
       .div4{
        
        color:red;
       }
      </style>
     <form action="Servlet?n=downland" method="post">
         <div class="div1"><center><b>河北金力集团公文流转系统</b></center></div>
      <div class="div2">
      <center>
      <div class="div3">
      <h7>用户名:</h7><input type="text" maxlength="20" id="username" name="username" onblur ="check()" />
      <div  class="div4" id="pwspan1"></div><br/>
      <center><h7>&nbsp;&nbsp;&nbsp;密码:</h7><input type="password" maxlength="15" id="password" name="password"  onblur="check1()">
      <div  class="div4" id="pwspan2"></div><br>
      <a href="#"><br/><center> <input name="submit" type="submit" class="btn_grey" value="登录"><br><a>
      </div>
      </center>
      </div>
         </form>
    </body>
    </html>
     
     
     
     
    package com.Servlet;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.Util.DBUtil;
    import bean.User;
    /**
     * Servlet implementation class Servlet
     */
    @WebServlet("/Servlet")
    public class Servlet extends HttpServlet {
     private static final long serialVersionUID = 1L;
          
        /**
         * @see HttpServlet#HttpServlet()
         */
        public Servlet() {
            super();
            // TODO Auto-generated constructor stub
        }
     /**
      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
      */
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
      request.setCharacterEncoding("UTF-8");
      response.getWriter().append("Served at: ").append(request.getContextPath());
      String id=request.getParameter("id");
      String username=request.getParameter("username");
      String password=request.getParameter("password");
      String permissionid=request.getParameter("permissionid");
      String job=request.getParameter("job");
      String status=request.getParameter("status");
      User user=new User();
      if(request.getParameter("n").equals("downland"))
      {
       String username1=request.getParameter("username");
       user.setUsername(username1);
       String password1=request.getParameter("password");
       user.setPassword(password1);
       DBUtil.dengluchaxun(user);
      }
      
      
      
      
     }
     /**
      * @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);
     }
    }
     
     
     
    package bean;
    public class User {
     protected int id;
     protected String username;
     protected String password;
     protected String permissionid;
     protected String job;
     protected int status;
     

     public int getId() {
      return id;
     }

     public void setId(int id) {
      this.id = id;
     }

     public String getUsername() {
      return username;
     }

     public void setUsername(String username) {
      this.username = username;
     }

     public String getPassword() {
      return password;
     }

     public void setPassword(String password) {
      this.password = password;
     }

     public String getPermissionid() {
      return permissionid;
     }

     public void setPermissionid(String permissionid) {
      this.permissionid = permissionid;
     }

     public String getJob() {
      return job;
     }

     public void setJob(String job) {
      this.job = job;
     }

     public int getStatus() {
      return status;
     }

     public void setStatus(int status) {
      this.status = status;
     }
    }
  • 相关阅读:
    Multimodal —— 看图说话(Image Caption)任务的论文笔记(一)评价指标和NIC模型
    机器学习 —— 基础整理(六)线性判别函数:感知器、松弛算法、Ho-Kashyap算法
    机器学习 —— 基础整理(五)线性回归;二项Logistic回归;Softmax回归及其梯度推导;广义线性模型
    机器学习 —— 基础整理(四)特征提取之线性方法:主成分分析PCA、独立成分分析ICA、线性判别分析LDA
    Windows 安装 Maven 及 Eclipse 安装Maven插件
    ubuntu server 12.04 jdk,ssh及hadoop配置
    利用Google Chrome开发插件,在网页中植入js代码
    Ubuntu Server 12.04 LTS搭建SVN服务及修改端口
    MongoDB的基本使用
    hibernate初使用
  • 原文地址:https://www.cnblogs.com/yangqqq/p/12012491.html
Copyright © 2020-2023  润新知