读书人

hsqldb施用

发布时间: 2012-10-08 19:54:56 作者: rapoo

hsqldb使用

hsqldb有下面几种模式

1.Server模式

首先要启动server 端:

例如,在命令行窗口执行:

   1.  public class Test {      2.      3.     public static void main(String[] args){      4.         try{          5.             Class.forName("org.hsqldb.jdbcDriver");                6.             Connection conn = DriverManager.getConnection("jdbc:hsqldb:file:C:/hsqldb/testdb4/mydb4","sa","");          7.             Statement  st = conn.createStatement(); // statement objects can be reused with          8.             ResultSet  rs = st.executeQuery("select * from users"); // run the query          9.             while(rs.next()){        10.                 String s1=rs.getString("name");         11.                 System.out.println(s1);     12.             }     13.             st.close();         14.             st = conn.createStatement();         15.             st.execute("SHUTDOWN");         16.             conn.close(); // if there are no other open connection         17.             }catch(Exception e){         18.                 e=null;         19.                 e.printStackTrace();     20.             }        21.     22.     }     23. }  

读书人网 >其他数据库

热点推荐