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>