File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JDBC - HSQLDB problem... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC - HSQLDB problem..." Watch "JDBC - HSQLDB problem..." New topic

JDBC - HSQLDB problem...

Raul Martinez

Joined: Mar 01, 2004
Posts: 17
I am writing a simple Java application that queries an HSQLDB 'server mode' database.
I have a table called

ENT_ID int
ENT_FROM varchar(..)
ENT_MSG varchar(..)
ENT_DATE varchar(..)
ENT_TIME varchar(..)

I use GB_DATA table to store guestbook entry. My java code contains,

" FROM gb_data order by ent_date desc, ent_time desc ";
try {
st = conn.createStatement();
rs = st.executeQuery(sqlQuery);
meta = rs.getMetaData();
int colCount = meta.getColumnCount();
String[] fieldNames = new String[colCount];
for (int x =0; x < colCount; x++) {
fieldNames[x] = meta.getColumnName(x);
} catch (SQLException se) {
throw new SQLException (se.getMessage() + " - getEntries");

--- when executing the code, database connection is successful.. but during the executeQuery(..)
statement, the it throws an SQLException with message :

Column not found: 0 getEntries

About the table (GB_DATA)
I used HSQL Database Manager to issue a create table command to be able to create
the GB_DATA table. Is this the problem??

I'm totally confused with the error since, the columns in my SELECT statement are all
valid and exists in GB_DATA


Learning new things, I LIKE!<p>---certification---<br />none so far, experience (considerable, yeah)
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Yeah, tricky stuff.
For some reason JDBC related things start at an index of 1 instead of 0.
Try revising your for loop to start at 1.

[ March 02, 2004: Message edited by: James Swan ]
Raul Martinez

Joined: Mar 01, 2004
Posts: 17
solved! thanks!
I agree. Here's the link:
subject: JDBC - HSQLDB problem...
jQuery in Action, 3rd edition