using jdbc with hsqldb

View: New views
1 Messages — Rating Filter:   Alert me  

using jdbc with hsqldb

by richardz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 Here is a hsqldb database ,the name is 'example' which contains a table 'student'.
I use the following codes to connect to the hsqldb database and get data from the database:
try{
                Class.forName("org.hsqldb.jdbcDriver");
                String url="jdbc:hsqldb:D\\hsqldb_db\\example"; //in windows
                conn = DriverManager.getConnection(url,"sa","");
                PreparedStatement preparedstatement;
                preparedstatement=conn.prepareStatement("SELECT * FROM student");
                ResultSet r=preparedstatement.executeQuery();
                if(r.next())
                {
                        Long b=r.getLong("id");
                        System.out.println(b);
                }  
                conn.close();
                System.out.println(conn);
                }
                catch(Exception e)
                {e.printStackTrace();}
                finally
                {conn.close();}

It seems that I connect to the database 'example' successfully but there come ups an exception:
java.sql.SQLException: Table not found: student in statement [SELECT * FROM student]

I'm sure the table student exists,because  I can see it using the hsqldb gui tool,and if I create a table using jdbc,I cann't find it using the hsqldb gui tool.
I explorer my problem in google,and I found many persons have the same puzzle and until now I found no solution to it.

Thanks in advance!
LightInTheBox - Buy quality products at wholesale price