Good news! It's getting correct results:
INFO QueryLogger: show table status
INFO QueryLogger: === returned 34 rows. - took 86 ms.
Exception in thread "main" INFO QueryLogger: +++ no commit -
transaction controlled externally.
java.lang.ClassCastException: org.objectstyle.cayenne.DataRow
at
com.statistics.ComputeStatistics.getcsDiskSpace(ComputeStatistics.java:838)
at com.statistics.MainStatistics.main(MainStatistics.java:66)
It recieved the correct number of rows (34), but when I try to access
them, I get errors. I've tried using an arbitrary class, and creating a
model in cayenne especially for the "show table status" table, with
attributes "Data_length" etc, so I have the correct getters and setters,
but no luck...
Is there a way to extract generic data form an undefined "Map"?
Many Thanks
Jack
Andrus Adamchik wrote:
Just try it :-)
Don't forget to call "setFetchingDataRows(true)" as mentioned by
Michael. This is what makes the difference. The result will be a list of
Maps.
Andrus
On Jul 20, 2007, at 8:45 PM, Jack O'Connor wrote:
OK, but then if I use
SQLTemplate select = new SQLTemplate(Artist.class, "show table status");
List artists = dataContext.performQuery(select);
Surely I will have Artist objects, and will only be able to use that
classes defined "getters and setters"? i.e. How will I extract data
from columns: data_length and index_length?
Thanks
Jack
Andrus Adamchik wrote:
In this case it is needed to pick the right database (Cayenne
potentially can access more than one). You can use an arbitrary class
from your model in this case.
Andrus
On Jul 20, 2007, at 5:24 PM, Jack O'Connor wrote:
Thanks for the reply, but all the SQLTemplates on that page require
a class/table to refer to (all the examples are for Artist.class).
The MySQL command "show table status" doesn't apply to any
particular class...
Jack
Michael Gentry wrote:
I would think you'd be able to use an SQLTemplate to perform that
kind of query:
http://cayenne.apache.org/doc20/sqltemplate-query.html
You'll want to call setFetchingDataRows(true) on your SQLTemplate
object, too, otherwise Cayenne will try to make CayenneDataObjects out
of it. Do this before you run performQuery().
/dev/mrg
On 7/19/07, Jack O'Connor <[EMAIL PROTECTED]> wrote:
Hi all, in my project I need to extract the total db size(kb). Im
using
Cayenne 1.2.3 and MySQL and I found the SQL command "show table
status
from <db name>" which displays a table of information about all of
the
tables in a certain db. This table has columns like "Name"(of table),
"Data_length" and "Index_length", and apparently the best way to
extract
the size(kb) of a db is to sum the Data_length and Index_length
columns
of this table.
Does anyone know how I can get the results of this query into java?
Many Thanks
Jack