Windows under JSP link MySQL (JDBC) myeclipse

Source: Internet
Author: User

Download the JDBC Driver first:


Transmission Door



Create a database in MySQL


Create DATABASE books;


Create tables, insert data, and more:


Use books;
CREATE TABLE book (bookId varchar), BookName varchar (+), Publishervarchar (+), price float,constraint Pk_book PrimaryKey (bookId))type=myisam,default character set GBK; (bold font is the default font that I fixed when I was building a table, Because I didn't use JAVAMXJ's practice of adding My.ini files in Windows)

Insert into book values (' 1001 ', ' Tomcat and Java Web Development Technology ', ' electronic industry Press ', 45.00);
Insert into book values (' 1002 ', ' Mastering struts: Java Web design and development based on MVC ', ' Electronic industry Press ', 49.00);
Insert into book values (' 1003 ', ' proficient in Hibernater:java object Persistence technology ', ' electronics Press ', 59.00);
Insert into book values (' 1004 ', ' proficient in EJB ', ' electronics Press ', 59.00);
Insert into book values (' 1005 ', ' EE application with Bea Weblogic Server ', ' electronic industry Press ', 56.00);



2. Next, build a Web project named MySQL in MyEclipse:



3, the establishment of mysql.jsp file. Enter the following code:


<span style= "FONT-SIZE:14PX;" ><%@ page contenttype= "text/html; charset=gb2312 "language=" java "import=" java.sql.* "%>
  

4. Copy the Mysql-connector-java-3.1.10-bin.jar file to the Tomcat\common\lib


Note: This directory is only limited to Tomcat 6.0 or less 6.0.


6.0 Workaround: Place the driver under the \webroot\web-inf\lib of the corresponding project.


5. You can run the JSP file in Eclipse.

6. Operation Result:



Many people are not connected to the database The most reason is also the Web. xml file problem.
Here is lomboz automatically generated Web. xml:

<span style= "FONT-SIZE:14PX;" ><?xml version= "1.0" encoding= "UTF-8"? ><web-app id= "webapp_id" version= "2.4" xmlns= "http://java.sun.com /xml/ns/j2ee "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" http://java.sun.com/xml/ Ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">    <display-name>    mysql</ display-name>    <welcome-file-list>        <welcome-file>index.html</welcome-file>        <welcome-file>index.htm</welcome-file>        <welcome-file>index.jsp</welcome-file>        <welcome-file>default.html</welcome-file>        <welcome-file>default.htm</welcome-file>        <welcome-file>default.jsp</welcome-file>    </welcome-file-list></web-app></ Span>


Windows under JSP link MySQL (JDBC) myeclipse

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.