hello,
I am trying to use hsqldb in jboss-4.0.5.GA .I tried the following small
jdbc code .
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
class JDBC_test
{
public static void main(
String args[])
{
Connection conn=null;
Statement select=null;
try
{
Class.forName("org.hsqldb.jdbcDriver");
System.out.println("Driver loaded...");
}
catch(Exception e)
{
System.out.println("Failed to load hsql driver.");
return;
}
try
{
conn = DriverManager.getConnection("jdbc:hsqldb:file:mydemo","sa","");
System.out.println("connected to hsql..");
select = conn.createStatement();
System.out.println("after create statement..");
}
catch(Exception e) {System.out.println("create statement failed");}
try
{
ResultSet result = select.executeQuery("select id,item from demo");
System.out.println("Got results:");
while (result.next())
{ // process results one row at a time
int key = result.getInt(1);
String val = result.getString(2);
System.out.println("key = " + key);
System.out.println("val = " + val);
}
} catch (Exception e) {
e.printStackTrace();}
finally
{
if(conn!=null)
{
System.out.println("conn is not null");
try { conn.close(); }
catch(Exception e){e.printStackTrace();}
}
}
}
}
I have a db named mydemo with table demo created with few columns in the stand alone mode.
If I try the same query in hsqldb it works fine.
But I am getting the following error while running thru this jdbc code
Driver loaded...
connected to hsql..
after create statement..
java.sql.SQLException: Table not found in statement [select id,item from demo]
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source)
at JDBC_test.main(JDBC_test.java:36)
conn is not null
Can anyone please help me out with this error?
thanks and regards,
nivas.