views:

47

answers:

3

my question is im getting d jtable but i want to display the data from the database into the the jtable. if i pass data directly its being displayed in the jtable but i wont data from the database.. please help the problem is in this line:

           private String[][] row1=new String[][]{jono,jdate,prname};

jono,jdate and prname are the variables that contain the data from database. i need to display it in jtable.

+1  A: 

Most likely jono, jdate, and prname are not instances of String[]. Post the error and the declaration of those variables for more help.

Matthew Flaschen
+5  A: 

Of course, you declare a two dimensional array but the initialization is just one dimension.

Try this:

private String[][] row1=new String[][]{{jono,jdate,prname}};
nanda
+2  A: 

You're creating a matrix (2-dimensional array) but are only instantiating single-dimensional objects.

The declaration should look something like this:

String[][] row1 = new String[][] { 
    new String[] { jono },
    new String[] { jdate },
    new String[] { prname }
};

Without knowing much else about what you are doing, I can't be certain if this would be what you would need, but it's a start.

rakuo15