JSP Connection Database

Source: Internet
Author: User

JSP connection MySQL Database steps:

1. Create MySQL Database script:

Use Uestc;create table emp (empno INT (4)     PRIMARY key,ename varchar (ten), Job VARCHAR (9), HireDate date,sal FLOAT (7,2)); INSERT into EMP (empno,ename,job,hiredate,sal) VALUES (6060, ' Zhang San ', ' manager ', ' 2001-09-16 ', 2000.30); INSERT into EMP (empno, Ename,job,hiredate,sal) VALUES (7369, ' John Doe ', ' sales ', ' 2003-10-09 ', 1500.90); INSERT into EMP (empno,ename,job,hiredate,sal) VALUES (7698, ' Harry ', ' Sales ', ' 2005-03-12 ', ' n '), insert into EMP (empno,ename,job,hiredate,sal) VALUES (7762, ' Zhao Liu ', ' Sales ', ' 2005-03-09 ', +); INSERT into EMP (empno,ename,job,hiredate,sal) VALUES (7782, ' Yang Seven ', ' analyst ', ' 2005-01-12 ', 2500); insert into EMP (empno,ename,job,hiredate,sal) VALUES (7839, ' Zhu Eight ', ' manager ', ' 2006-09-01 ', 2500); INSERT into EMP (Empno,ename,job, Hiredate,sal) VALUES (8964, ' money Nine ', ' analyst ', ' 2003-10-01 ', 3000);

2, the MySQL database executes step 1 script, input SELECT * from EMP, the query results as shown;


3. Copy the MySQL driver to the Tomcat6.0\lib directory;

4, write the JSP program listemp.jsp,jsp program as follows:

<%@ page contenttype= "text/html" pageencoding= "GBK"%><%@ page import= "java.sql.*"%>5, enter the virtual path name on the browser http://localhost/uestc/, find the listemp.jsp file, click Open, the results shown are as follows:


Display results show that the JSP program successfully read the MySQL database information, JSP and MySQL connection success!


JSP Connection Database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.