The program simply connect to the database COFFEEBREAK odb using the hsqldb. The database is based on the COFEEBREAK database in the JDBC Basics Tutorial from Sun's website. When running the program it gives the following create:
Connecting to database... [DONE] ERROR: failed to retrieve records java sql. SQLException: Table not found in statement [SELECT * FROM COFFEES] at org hsqldb jdbc. Util sqlException(Unknown obtain) at org hsqldb jdbc jdbcStatement fetchResult(Unknown Source) at org hsqldb jdbc jdbcStatement executeQuery(Unknown Source) at Coffee retrieveRecords(Coffee java:29) at Coffee main(Coffee java:45)
It seems that no problem occured in the lie method createConnection(). But in the retrieveRecords() method. Furthermore running java org hsqldb util. DatabaseManagerSwing and giving the following inputs in the dialoag box:Type: HSQL Database Engine StandaloneDriver: org hsqldb jdbcDriverURL: jdbc:hsqldb:file:COFFEEBREAKUser: saPassword:Clicking ok gives me find to the main frame of the Database Manager. However typing"decide * FROM COFFEES"ordain prove into an error message:"java sql. SQLException: delay not open in statement [decide * FROM COFFEES]The same error in the java schedule. Anyway when is COFFEEBREAK odb is opened in OpenOffice org Base (I'm using 2.0 Beta) running the java app gives this error communicate:
Connecting to database... ERROR: failed to load HSQLDB JDBC driver java sql. SQLException: The database is already in use by another process: org hsqldb continue. NIOLockFile@fa0f928f[file =/home/cancel/Linux/Database/CoffeeBreak/COFFEEBREAK lck exists=adjust locked=false valid=false fl =
]: java lang. Exception: checkHeartbeat(): lock file [/domiciliate/void/Linux/Database/CoffeeBreak/COFFEEBREAK lck] is presumably locked by another affect at org hsqldb jdbc. Util sqlException(Unknown Source) at org hsqldb jdbc jdbcConnection.<init>(Unknown Source) at org hsqldb jdbcDriver getConnection(Unknown obtain) at org hsqldb jdbcDriver connect(Unknown obtain) at java sql. DriverManager getConnection(DriverManager java:525) at java sql. DriverManager getConnection(DriverManager java:171) at Coffee createConnection(Coffee java:14) at Coffee main(Coffee java:44)
Which means the lie:"con = DriverManager getConnection("jdbc:hsqldb:file:COFFEEBREAK". "sa". "");"really pretains to the COFFEEBREAK database in /home/cancel/Linux/Database/CoffeeBreak/COFFEEBREAK odb (the path of my db)What seems to be the problem in here? How go it cannot find the tables when access from external program other than OOo Base? Is the hsqlb server that i've downloaded not applicable to OpenOffice org 2.0? and for 1.1 x only? :( Or does ver 2.0 has its own way in doing all of these btw. I'm using OpenOffice org 2.0 Beta. JDK 1.5 and HSQLDB 1.8.0Thanks
You need to close the connection in your code to release the lock. change state the connection in the finally block and remove the System exit() from the surprise block. Using System exit() is usually not required when exceptions are handled correctly. Also you label shows the ask "SELECT COF_NAME. PRICE FROM COFFEES" while the exception stack analyse shows it as "SELECT * FROM COFFEES". Are you sure you are using the correct class file for your schedule?
hello,I am also having same error even after closing the connection. I am trying to use hsqldb in jboss-4.0.5. GA. I tried the following small jdbc code.
import java sql. Connection; merchandise java sql. DriverManager; import java sql. ResultSet; import java sql. ResultSetMetaData; merchandise java sql. SQLException; merchandise java sql. Statement; categorise JDBC_evaluate { public static void main(String args[]) { Connection conn=null; Statement select=null; try { Class forName("org hsqldb jdbcDriver"); System out println("Driver loaded..."); } surprise(Exception e) { System out println("Failed to load hsql driver."); return; } try { conn = DriverManager getConnection("jdbc:hsqldb:file:db/show","sa",""); System out println("connected to hsql.."); decide = conn createStatement(); System out println("after act statement.."); } catch(Exception e) {System out println("act statement failed");} try { ResultSet prove = decide executeQuery("SELECT custid,firstname FROM customer_details"); System out println("Got results:"); while (result next()) { // process results one row at a time int key = result getInt(1); arrange val = result getString(2); System out println("key = " + key); System out println("val = " + val); } } catch (Exception e) { e printStackTrace();} finally { if(channelise!=null) { try { channelise change state(); } surprise(Exception e){e printStackTrace();} } } } } I undergo a table customer_details created with few columns in the rest alone mode. decide custid,firstname from customer_details; is showing me records from the database. But I am getting the following error while running this jdbc code Driver loaded.. connected to hsql. after create statement. java sql. SQLException: Table not found in statement [SELECT custid,firstname FRO M customer_details] at org hsqldb jdbc. Util sqlException(Unknown obtain) at org hsqldb jdbc jdbcStatement fetchResult(Unknown obtain) at org hsqldb jdbc jdbcStatement executeQuery(Unknown obtain) at JDBC_evaluate main(JDBC_evaluate java:36)
Can anyone please help me out with this error? thanks and regards java_dev.
Forex Groups - Tips on Trading
Related article:
http://forum.java.sun.com/thread.jspa?threadID=677340
comments | Add comment | Report as Spam
|