Hsqldb In Memory

阅读更多
public static void main(String[] args)   
    {  
        Connection connection;  
          
        try  
        {  
            Class.forName("org.hsqldb.jdbcDriver");  
            connection=DriverManager.getConnection("jdbc:hsqldb:mem:demodb","sa","");  
            Statement st=null;  
            ResultSet rs=null;  
              
            st=connection.createStatement();  
              
            String sql1="create table cuser(username varchar(10))";  
            String sql2="insert into cuser(username) values('wanjun')";  
            String sql3="select * from cuser";  
              
            st.executeUpdate(sql1);  
            st.executeUpdate(sql2);  
              
            rs=st.executeQuery(sql3);  
              
            while(rs.next())  
            {  
                System.out.println(rs.getString(1));  
            }  
        }   
        catch (Exception e)   
        {  
            e.printStackTrace();  
        }  
          
    }  

你可能感兴趣的:(hsqldb)