Chinaunix首页 | 论坛 | 博客
  • 博客访问: 30465002
  • 博文数量: 708
  • 博客积分: 12163
  • 博客等级: 上将
  • 技术积分: 8240
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-04 20:59
文章分类

全部博文(708)

分类: 数据库开发技术

2011-09-15 15:53:43

使用server模式启动数据库

runServer.bat
@java -classpath ./hsqldb.jar org.hsqldb.Server %1 %2 %3 %4 %5 %6 %7 %8 %9

web application:

  1. public class ViewRecords extends HttpServlet {
  2.     Connection con;
  3.     @Override
  4.     public void init() throws ServletException {
  5.         try {
  6.             Class.forName("org.hsqldb.jdbcDriver");
  7.         } catch (ClassNotFoundException e) {
  8.             e.printStackTrace(System.out);
  9.         }
  10.         try {
  11.             con=DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/labdb","SS","");
  12.         } catch (SQLException e) {
  13.             e.printStackTrace(System.out);
  14.         }
  15.     }
  16.     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  17.         response.setContentType("text/html");
  18.         PrintWriter out=response.getWriter();
  19.         try {
  20.             PreparedStatement pst=con.prepareStatement("select * from PROJECT");
  21.             pst.clearParameters();
  22.             ResultSet rs=pst.executeQuery();
  23.             while(rs.next()){
  24.                 out.write("
    "
    +rs.getString(1));
  25.                 out.write(", "+rs.getString(2));
  26.                 out.write(", "+rs.getString(3));
  27.                 out.write(", "+rs.getString(4));
  28.             }
  29.             out.write("
    Home "
    );
  30.         } catch (SQLException e) {
  31.             e.printStackTrace(System.out);
  32.         }
  33.     }

  34. }

HSQL Database Manager:

Type: HSQL Database Engine Server

URL:jdbc:hsqldb:hsql://localhost/labdb

阅读(1854) | 评论(0) | 转发(0) |
0

上一篇:雨中登泰山

下一篇:hsqldb 日期

给主人留下些什么吧!~~