Board index » jbuilder » displaying query in a servlet

displaying query in a servlet


2005-02-14 12:40:18 AM
jbuilder2
Hi
Im having trouble with a servlet displaying the contents of a query. Im just
testing the code out, its not a proper application, I just want to see what
I can do.
Anyway I have a database connected, and I have created a query which dispays
one of the records, the servlet will then display that record on a page
using the PrintWriter method. and using this code String test =
coordxquery.getstring("roomcoordX");
and then printing by using out.printin(test)
Problem is everytime I try and create this I get a tomcat error.
See com.borland.dx.dataset.DataSetException error code: BASE+10
com.borland.dx.dataset.DataSetException: Unknown column name: roomcoordX
at com.borland.dx.dataset.DataSetException.c(Unknown Source)
I realise its the column name Im having probkems with, but I thought I had
created the code to query this:
database1.setConnection(new ConnectionDescriptor("jdbc:odbc:database", "",
"", true, "sun.jdbc.odbc.JdbcOdbcDriver"));
coordxquery.setSchemaName("");
coordxquery.setSort(new com.borland.dx.dataset.SortDescriptor("",
new String[] {"roomcoordX"}, new boolean[] {true, }, null, 0));
coordxquery.setAccumulateResults(true);
coordxquery.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(
database1, "SELECT roomcoordX FROM tblroom GROUP BY
tblroom.roomcoordX", null, true,
Load.ALL));
Ok I know its probably something simple, and im proving that Im a right
newb, but can anybody help with this?
Thank you
Paul
 
 

Re:displaying query in a servlet

Paul Iddon wrote:
Quote
Hi

Im having trouble with a servlet displaying the contents of a query.
Im just testing the code out, its not a proper application, I just
want to see what I can do.

Anyway I have a database connected, and I have created a query which
dispays one of the records, the servlet will then display that record
on a page using the PrintWriter method. and using this code String
test = coordxquery.getstring("roomcoordX");
and then printing by using out.printin(test)

Problem is everytime I try and create this I get a tomcat error.

See com.borland.dx.dataset.DataSetException error code: BASE+10
com.borland.dx.dataset.DataSetException: Unknown column name:
roomcoordX at com.borland.dx.dataset.DataSetException.c(Unknown
Source)

Your "GROUP BY" makes me a little suspicious; while the column exists
in the database (your query obviously works) there's no guaranteed that
the column name will be preserved in a "GROUP BY" clause. Remove the
"GROUP BY" and see what happens.
Alternately, print out the columns from the query data set by using
getColumn() and getColumnCount() and see what's available.
--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
www.datadevelopment.com/
Please see Borland's newsgroup guidelines at
info.borland.com/newsgroups/guide.html
 

Re:displaying query in a servlet

Thanks for that, I removed the group by and tried the getColumn ect. But it
still doesnt work! Any other ideas?
Thank You
Paul
"Kevin Dean [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
Paul Iddon wrote:

>Hi
>
>Im having trouble with a servlet displaying the contents of a query.
>Im just testing the code out, its not a proper application, I just
>want to see what I can do.
>
>Anyway I have a database connected, and I have created a query which
>dispays one of the records, the servlet will then display that record
>on a page using the PrintWriter method. and using this code String
>test = coordxquery.getstring("roomcoordX");
>and then printing by using out.printin(test)
>
>Problem is everytime I try and create this I get a tomcat error.
>
>See com.borland.dx.dataset.DataSetException error code: BASE+10
>com.borland.dx.dataset.DataSetException: Unknown column name:
>roomcoordX at com.borland.dx.dataset.DataSetException.c(Unknown
>Source)
>

Your "GROUP BY" makes me a little suspicious; while the column exists
in the database (your query obviously works) there's no guaranteed that
the column name will be preserved in a "GROUP BY" clause. Remove the
"GROUP BY" and see what happens.

Alternately, print out the columns from the query data set by using
getColumn() and getColumnCount() and see what's available.

--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
www.datadevelopment.com/

Please see Borland's newsgroup guidelines at
info.borland.com/newsgroups/guide.html
 

{smallsort}

Re:displaying query in a servlet

Paul Iddon wrote:
Quote
Thanks for that, I removed the group by and tried the getColumn ect.
But it still doesnt work! Any other ideas?
What columns do you get when you enumerate them using getColumnCount()
and getColumn()?
--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
www.datadevelopment.com/
NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
www.datadevelopment.com/papers/index.html
Please see Borland's newsgroup guidelines at
info.borland.com/newsgroups/guide.html