使用server模式启动数据库
runServer.bat
@java -classpath ./hsqldb.jar org.hsqldb.Server %1 %2 %3 %4 %5 %6 %7 %8 %9
web application:
- public class ViewRecords extends HttpServlet {
-
Connection con;
-
@Override
-
public void init() throws ServletException {
-
try {
-
Class.forName("org.hsqldb.jdbcDriver");
-
} catch (ClassNotFoundException e) {
-
e.printStackTrace(System.out);
-
}
-
try {
-
con=DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/labdb","SS","");
-
} catch (SQLException e) {
-
e.printStackTrace(System.out);
-
}
-
}
-
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
response.setContentType("text/html");
-
PrintWriter out=response.getWriter();
-
try {
-
PreparedStatement pst=con.prepareStatement("select * from PROJECT");
-
pst.clearParameters();
-
ResultSet rs=pst.executeQuery();
-
while(rs.next()){
-
out.write("
"+rs.getString(1));
-
out.write(", "+rs.getString(2));
-
out.write(", "+rs.getString(3));
-
out.write(", "+rs.getString(4));
-
}
-
out.write("
Home ");
-
} catch (SQLException e) {
-
e.printStackTrace(System.out);
-
}
-
}
-
-
}
HSQL Database Manager:
Type: HSQL Database Engine Server
URL:jdbc:hsqldb:hsql://localhost/labdb
阅读(1854) | 评论(0) | 转发(0) |