I'm using a method getTableContent that fetch some values from the db and returns as String array. The methods goes as follows,
public static String[][] getTableContent(Connection con){
ResultSet rs = null;
Statement st = null;
String [][] data = null;
String sql = "select COF_NAME, SUP_ID, PRICE, SALES, TOTAL from COFFEES";
try {
st = myConn.createStatement();
rs = st.executeQuery(sql);
if(rs.last()){
data = new String[rs.getRow()][5];
rs.beforeFirst();
}
int count =0;
while ( rs != null && rs.next() ){
data[count][0] =rs.getString(1);
data[count][1] =rs.getString(2);
data[count][2] =rs.getString(3);
data[count][3] =rs.getString(4);
data[count][4] =rs.getString(5);
}
}
catch (SQLException e) {
e.printStackTrace();
}
return data;
}
I get the table values in another array and trying to print as following,
String [][] myData = getTableContent(conn);
for ( int i =0; i < myData.length; i++ ){
for ( int j =0; j < myData.length; j++ ){
System.out.print( (myData[j]) + " ");
}
System.out.println();
}
All I'm getting some machine values provided below as sample ,
[Ljava.lang.String;@314e4baf [Ljava.lang.String;@4cb71983
I used myData[j]).toString() but that doesn't help me. How can I improve the code ? There are no error in the program.