SQL是Structured Query Language(结构化查询语言)的缩写。SQL是专为数据库而建立的操作命令集,是一种功能齐全的数据库语言。在使用它时,只需要发出“做什么”的命令,“怎么做”是不用使用者考虑的。SQL功能强大、简单易学、使用方便,已经成为了数据库操作的基础,并且现在几乎所有的数据库均支持SQL。
select column... from table。
select column...from table where 1=1
<!DOCTYPE html><html><head><meta charset="UTF-8"><style>span {display: inline-block;width: 75px;margin-bottom: 15px;}</style><title>动态查询</title></head><body><form action="http://localhost:8080/JavaSETest/dynamicQueryServlet"><div><span>姓名:</span><input type="text" name="name"></div><div><span>性别:</span><input type="text" name="sex"></div><div><span>年龄:</span><input type="text" name="age"></div><div><span>部门编号:</span><input type="text" name="depNo"></div><div><input type="submit"value="查询"> <input type="reset"value="重置"></div></form></body></html>
"/dynamicQueryServlet" DynamicQueryServlet serialVersionUID = 1L "text/html;charset=UTF-8"String name = request.getParameter("name"= request.getParameter("sex"= request.getParameter("age"= request.getParameter("depNo"String baseSQL = "select name,sex,age,depNo from tb_employee where 1=1"= StringBuilder();List<String> params = ArrayList<String>" and name=? ""name," + name);" and sex=? ""sex," +" and age=? ""age," +" and depNo=?""depNo," += = = = == ( i = 0; i < params.size(); i++== str.split(","); (arr[0].equals("age" a = Integer.parseInt(arr[1+ 1+ 1, arr[1== res.getString("name"= res.getString("sex" targetAge = res.getInt("age"= res.getString("depNo"= "name=" + targetName + "--" + "sex=" + targetSex + "--" + "age=" + targetAge + "--"
+ "depNo=" ++ "<br>" (ClassNotFoundException