新建表:Test-----右键Create Table-----在表中添加字段
一、项目与数据库连接
1.修改数据库登录用户名和密码,连接数据库
context.xml(片段)
type="javax.sql.DataSource"driverClassName="com.mysql.jdbc.Driver"
username="root"
password="root"
url="jdbc:mysql://localhost:3306/test"
useUnicode="true"characterEncoding="UTF-8"
maxIdle="2"maxWait="5000"maxActive="4"/>
二、检索
分析:
在UserSqlMap.xml中查询表中userID为admin的字段,存入bean中
从bean中取出数据,附給frm,然后以它的值作为检索条件去数据库中检索
将DB中取出的字段传到login页面
//设置一个命名空间
parameterClass="cn.training.bean.UserBean" //parameterClass用来存放
resultClass="cn.training.bean.UserBean"> //将查询到的值放入resultClass中