<%@ 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>
jsp使用传入参数作为查库参数
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
lsblk命令参数详解
lsblk命令用于列出块设备的信息,包括磁盘、分区和挂载点等。下面是lsblk命令的一些常用用法和示例讲解:
CentOS lsblk命令 Linux