JDBC error "Table not found in Statement"

M

mike

I am trying to use JDBC to connect to an OpenOffice Database (hsqldb).
When I try to run a query I get an error that says "Table not found in
Statement [Select * from MemberInfo]. MemberInfo being the table. I
get the SQLException on a query, but I am not sure why. As far as I
know, my code is all correct. I have never done database connections,
so I am not really sure how to check if the Connection object is
actually hooked to the database. It doesn't throw any exceptions
though, until I try to run the query. When I make the connection I am
doing

conn =
DriverManager.getConnection("jdbc:hsqldb:/home/username/project/whatever.odb","sa","");

then I have this
ResultSet rs = conn.createStatement().executeQuery("SELECT * from
MemberInfo);


Any ideas?


ps) if needed I can post more code.


Mike
 
I

IchBin

mike said:
I am trying to use JDBC to connect to an OpenOffice Database (hsqldb).
When I try to run a query I get an error that says "Table not found in
Statement [Select * from MemberInfo]. MemberInfo being the table. I
get the SQLException on a query, but I am not sure why. As far as I
know, my code is all correct. I have never done database connections,
so I am not really sure how to check if the Connection object is
actually hooked to the database. It doesn't throw any exceptions
though, until I try to run the query. When I make the connection I am
doing

conn =
DriverManager.getConnection("jdbc:hsqldb:/home/username/project/whatever.odb","sa","");

then I have this
ResultSet rs = conn.createStatement().executeQuery("SELECT * from
MemberInfo);


Any ideas?


ps) if needed I can post more code.


Mike
try this..

DriverManager.getConnection("jdbc:hsqldb:file:/home/username/project/whatever.odb","sa","");



--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
I

IchBin

IchBin said:
mike said:
I am trying to use JDBC to connect to an OpenOffice Database (hsqldb).
When I try to run a query I get an error that says "Table not found in
Statement [Select * from MemberInfo]. MemberInfo being the table. I
get the SQLException on a query, but I am not sure why. As far as I
know, my code is all correct. I have never done database connections,
so I am not really sure how to check if the Connection object is
actually hooked to the database. It doesn't throw any exceptions
though, until I try to run the query. When I make the connection I am
doing

conn =
DriverManager.getConnection("jdbc:hsqldb:/home/username/project/whatever.odb","sa","");


then I have this
ResultSet rs = conn.createStatement().executeQuery("SELECT * from
MemberInfo);


Any ideas?


ps) if needed I can post more code.

Mike
try this..

DriverManager.getConnection("jdbc:hsqldb:file:/home/username/project/whatever.odb","sa","");
Just to iterate..
[just add the database name at the end and not both the name.extension]

DriverManager.getConnection("jdbc:hsqldb:file:/home/username/project/DatabaseNameOnly","sa","");

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
M

mike

Nope, same problem. I made the above changes:
conn =
DriverManager.getConnection("jdbc:hsqldb:file:/home/user/project/DBName","sa","");

I do get in the "/home/user/project" directory DBName.log,
DBName.properties, and DBName.script files.

The log file is now empty. The first time I ran it, it had:
CREATE USER SA PASSWORD "" ADMIN
but then I ran it again, and it cleared it out.

The properties file looks fine. The script file has the following:
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 20

I have searched on the internet and found others with the same problem,
but I am yet to find a solution.

Thanks.
 
I

IchBin

mike said:
Nope, same problem. I made the above changes:
conn =
DriverManager.getConnection("jdbc:hsqldb:file:/home/user/project/DBName","sa","");

I do get in the "/home/user/project" directory DBName.log,
DBName.properties, and DBName.script files.

The log file is now empty. The first time I ran it, it had:
CREATE USER SA PASSWORD "" ADMIN
but then I ran it again, and it cleared it out.

The properties file looks fine. The script file has the following:
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE USER SA PASSWORD ""
GRANT DBA TO SA
SET WRITE_DELAY 20

I have searched on the internet and found others with the same problem,
but I am yet to find a solution.

Thanks.
Well if your script file only has that information than there is no
table defined in that DB. That tells me that it just wrote the defaults
as if it was creating a new database. It will do that if it can not find
the database defined in initial jdbc connection string. It will just
create a new one based on that connect statement, automatically. This
would make sense with the error you said you where getting before as
Table not found.

Questions:

- When you created you Database under OpenOffice did you create just the
DB or create it and then create tables in it. If it created this
database with OpenOffice then where is this database you are trying to
connect to? It can't be the one from your jdbc statement.

WHAT type of tables do you have defined in that DB? That is, MEMORY,
CACHED or file..

Have you tested just using the runManager or the runManagerSwing?

If you created your DB under Openoffice then you can not have the
OpenOffice database design fronted opened against that db. You will have
to run the db under a hsqldb server. This changes your connection string
completely.

Problems like this are usually very simple. It USUALLY GET CONFUSING
because HSQLDB will create a database even if it is not the one you
think your connecting to. Also having OpenOffice, in the mix, and not
knowing HSQLDB makes for more confusion.

The best way to go about this, until you get a handle on it is to:

-Copy your DB, you created in OpenOffice, to a different subdirectory.
- Use either runManager or runManagerSwing to test you connection string
by hand. Inset data.. blabblabblab
- Once working translate that information to your program.

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
Joined
Aug 2, 2006
Messages
1
Reaction score
0
OpenOffice.org database files use the HSQL engine, however the files themselves are actually Zip files containing the HSQL database files and several XMl documents describing the forms, queries, and other information. You would need to unzip the file first. Sorry for the plug, but I wrote an article about this: http://digiassn.blogspot.com/2006/07/java-creating-jdbc-connection-to.html

Hopefully this will help you if this is still an issue for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top