首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

hsqldb施用

2012-10-08 
hsqldb使用hsqldb有下面几种模式1.Server模式首先要启动server 端:例如,在命令行窗口执行:1.public class

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. }  

热点排行