Database control

Hi all,

I managed to connect to a database and with a resultset, i have managed to OUTPUT the data retreived from the DB to the System.out.println. However now I would like to learn how to put the results on a sort of table. I was looking on the web and I found a Datagrid for .net. ... Does java has an alternative to this?

Thanks all

[354 byte] By [Xenobiusa] at [2007-11-27 7:41:36]
# 1
JTable
PhilHeina at 2007-7-12 19:22:15 > top of Java-index,Java Essentials,New To Java...
# 2
So.. there's nothing as automatic as a datagrid?thanks
Xenobiusa at 2007-7-12 19:22:15 > top of Java-index,Java Essentials,New To Java...
# 3
> So.. there's nothing as automatic as a datagrid?> > thanksNope.Override the AbstractTableModel, and you can make it automatic with a bit of work.
kevjavaa at 2007-7-12 19:22:15 > top of Java-index,Java Essentials,New To Java...
# 4

Hey all im still stuck!! Any examplish help please?

Lets say I have a result set which has already performed a successfull query.

Howcan I know:

How much columns are in the result set,

How much records and what is the name of each column.

With these 3 I can manage it but im not sure how and what to use to get these 3.

THANKS all

Xenobiusa at 2007-7-12 19:22:15 > top of Java-index,Java Essentials,New To Java...
# 5

> How much columns are in the result set,

I usually know this because I'm the chap who wrote the query, but if

you trying to write some general purpose code, you can:

ResultSetMetaData rsmd = rs.getMetaData();

int columnCount = rsmd.getColumnCount();

> How much records and what is the name of each column.

You can find column names in the ResultSetMetaData.

(Method getColumnLabel or perhaps getColumnName.)

The number of records is usually not something you need to know.

Instead, read the data into business objects, and add those to a list, or

if you are working with DefaultTableModel, create a row array or Vector

and add that to the model.

> THANKS all

Good luck.

Message was edited by:

Hippolyte

Hippolytea at 2007-7-12 19:22:15 > top of Java-index,Java Essentials,New To Java...
# 6
AA now that answered my question!Thanks man enjoy the dukes :D
Xenobiusa at 2007-7-12 19:22:15 > top of Java-index,Java Essentials,New To Java...