#How do i return data from sql as object[][] and put them somewhere like JTable?

1 messages ยท Page 1 of 1 (latest)

charred cradle
#

i really dont know howw thanks for the help in advance

supple galeBOT
#

<@&987246399047479336> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
I really dont know howw thanks for the help in advance

To return data from SQL as Object[][] and display it in a JTable in Java, you can follow these steps:

  1. Retrieve the data from your SQL database using JDBC.
  2. Store the data in a 2D array (Object[][]) format.
  3. Create a DefaultTableModel using the data.
  4. Set the DefaultTableModel as the model for your JTable.

Here's a basic example code snippet to get you started:

// Retrieve data from SQL database and store it in Object[][] arr

DefaultTableModel model = new DefaultTableModel(arr, columnNames);
JTable table = new JTable(model);

Useful links:

  1. How to populate JTable with ResultSet data
  2. Working with JTables
  3. JDBC Tutorial
charred cradle
#

Oh okay thanks!!

hybrid kelp
#

It totally missed the actual process for getting the data into an Object[][]

#

Can you describe the data you have in your database briefly?

#

(or will have)