File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC - HSQLDB problem..." Watch "JDBC - HSQLDB problem..." New topic
Author

JDBC - HSQLDB problem...

Raul Martinez
Greenhorn

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

GB_DATA
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,

String sqlQuery = " SELECT ENT_ID, ENT_FROM, ENT_MSG, ENT_DATE,ENT_TIME " +
" 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

jm


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
Greenhorn

Joined: Mar 01, 2004
Posts: 17
solved! thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC - HSQLDB problem...
 
Similar Threads
JTable
Not recognising names containing underscores [RESOLVED]
How must i "synchronize" my servlets?
Getting Last Record in Jtable
Unable to display data from access database