zoukankan      html  css  js  c++  java
  • jsp使用传入参数作为查库参数

    <%@ page contentType="text/html;charset=gb2312"%> 
    <%@ page import="java.sql.*"%> 
    
    <%
    Class.forName
    ("org.gjt.mm.mysql.Driver").newInstance(); 
    String url ="jdbc:mysql://localhost/com?user=root&password=nafio&useUnicode=true&characterEncoding=UTF-8"; 
    Connection conn= DriverManager.getConnection(url); 
    Statement stmt=conn.createStatement
    (ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_UPDATABLE); 
    %>
    
    <%
    String nameP = (String)request.getParameter("name");
    String passP = (String)request.getParameter("pass");
    %>
    
    <html> 
    <head> 
    <title> Title </title> 
    </head> 
    	
    <body>
    	<%
    		String num = "";
    		String sql = "select * from gua where name=""+nameP+""";
    		ResultSet rs=stmt.executeQuery(sql);
    		if(rs.next())num=rs.getString(4);
    		rs.close();
    	%>
    	测试:<%=sql %>
    	用户名:<%=nameP %>
    	密码:	<%=passP %>
    	查询结果:<%=num %>
    </body>
    </html>

  • 相关阅读:
    angular模板
    Growth: 全栈增长工程师指南
    全栈增长工程师实战
    vue 快速搭建项目 iview
    ng-style
    教程视频链接
    内置对象
    对象—封装、继承
    对象—构造函数
    函数-理论
  • 原文地址:https://www.cnblogs.com/nafio/p/9137732.html
Copyright © 2011-2022 走看看