Integrate hsql and tomcat in eclipse

Source: Internet
Author: User

1. Download eclipse and put it in a location such as C:/eclipse.

2. Download Tomcat and copy it to a folder in C:/eclipse, such as C:/Eclipse/apache-tomcat7

3. Set the server in the preference of the eclipse window, create a web project, create a new web page, and test it. You can run the web server.

4. Download hsql and run the server mode in BIN to create a new table.

Create Table persons (

Name char (50)

);

5. Set the database in eclipse, add the hsql statement, and then run database perspective to view the new SQL file. Then, run the following command to view the query result in results. And insert some records.

6. Add an external jar to the project, that is, HSQLDB. jar in hsql.

7. Create a New JSP in the project and call the data in the hsql.

<% @ Page Language = "Java" contenttype = "text/html; UTF-8"

 

Pageencoding = "UTF-8" %>

 

<% @ Page import = "org. HSQLDB. JDBC. *, java. SQL. *, java. util. *" %>

 

<! Doctype HTML>

 

<HTML>

 

<Head>

 

<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">

 

<Title> insert title here </title>

 

</Head>

 

<Body>

 

Aaa

 

<%

 

Try {

 

Class. forname ("org. HSQLDB. jdbcdriver ");

 

Connection conn = drivermanager. getconnection ("JDBC: HSQLDB: hsql: // localhost/", "sa ","");

 

Statement ST = NULL;

 

Resultset rs = NULL;

 

St = conn. createstatement ();

 

Rs = st.exe cutequery ("select * from persons ");

 

While (Rs. Next ()){

 

Out. Print (Rs. getstring ("name "));

 

}

 

}

 

Catch (exception e ){

 

E. printstacktrace ();

 

}

 

%>

 

B

 

</Body>

 

</Html>

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.