#How do i return data from sql as object[][] and put them somewhere like JTable?
1 messages ยท Page 1 of 1 (latest)
<@&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>.
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:
- Retrieve the data from your SQL database using JDBC.
- Store the data in a 2D array (
Object[][]) format. - Create a
DefaultTableModelusing the data. - Set the
DefaultTableModelas the model for yourJTable.
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:
- AI generated response
Oh okay thanks!!
Yeah, sorry about that answer from the bot
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)