After learning the JSP basic syntax and the use of HTML and JavaScript, JSP+JDBC connect the database to develop a dynamic Web page can be implemented.
For students who have studied Java SE, the operation of the database is not unfamiliar, if there are forgotten or will not be able to http://zhaoyuqiang.blog.51cto.com/6328846/1127658 learning.
What about the database connections in the JSP? How can we use the knowledge of HTML and JavaScript we've learned? This is the learning content of our article----JSP+JDBC access to the database.
We use an example to illustrate the JSP+JDBC Access database---user login instance. Just like the login mailbox, the user enters the account number and the password, if the correct word jumps to the homepage, if the error prompts or jumps to the error page. As shown in the following illustration:
First set up the database, the database test in MySQL, set up the table users. As shown in the following figure
After the database was built, the project was built in MyEclipse, and the MySQL driver package was directed into Lib.
Create the first JSP page----landing page login.jsp
<%@ page language= "java" contenttype= "text/html" pageencoding= "Utf-8"%>