标签:result 获取 where driver boolean cal local 实例化 numbers
在jsp中获取数据库数据
<% Class.forName("com.mysql.jdbc.Driver");//加载mysql驱动 Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/test1", "root", "3701211994812sls");//localhost是本机地址,3306是端口号,最后是用户名和密码 Statement stmt=conn.createStatement();//实例化Statement对象 String queryNumberSQL="SELECT * from p_user where username=‘"+name+"‘ and password=‘"+password+"‘"; ResultSet rs=stmt.executeQuery(queryNumberSQL);//执行数据库查询操作并获取结果集 boolean flag=false;//初始化flag if(rs.next()){//判断结果 flag=true; session.setAttribute("UserName", name);//将name的内容赋值给UserName }else{ flag=false; } %>
标签:result 获取 where driver boolean cal local 实例化 numbers
原文地址:https://www.cnblogs.com/kai0016/p/13205927.html