Hello everyone! I have been working on my school project and I have encountered problem linking jTable with a table in the sql server.Can anyone please help me regarding it.Please help me with the code on how to link the the table.

This should work

String sql = "SELECT row1, row2, row3 mysqltable";
                  ResultSet rs = stmt.executeQuery(sql);  
      //STEP 1: Extract data from result set
         //Retrieve by column name
         int row1  = rs.getInt("row1");
         String row2 = rs.getString("row2");
         String row3 = rs.getString("row3");
         //STEP 2 create an object array of the mysql data
    Object[] row = {row1,row1,row3};
    //STEP 3: add object array to jtable
        DefaultTableModel model = (DefaultTableModel) jTable1.getModel();

work out the rest

commented: very helpful i have been struggling for past 2 hours just to land here and 5 minutes am done . +0

Hi Zaraki (and Kriti)

Please note that it is DaniWeb's policy that posters should show some effort before we give them help. "Please do my homework for me" posts are usually either ignored or penalised.

Having said that... Z's post is good in that it points OP in the right direction without just giving a solution on a plate.

JC _ Moderator