I am connection to my DB and get data and column.
I want to print them:
public class JDBC1 {
static Vector<String> columns = new Vector<String>();
Vector<Vector<String>> data = new Vector<Vector<String>>();
Connection con;
Statement statement;
ResultSet result;
public Vector<String> getColumns() throws SQLException {
con = DriverManager.getConnection(...);
statement = con.createStatement();
result = statement.executeQuery("Select * from table");
int c = result.getMetaData().getColumnCount();
for (int i = 1; i <= c; i++) {
columns.add(result.getMetaData().getColumnName(i));
}
return columns;
}
public Vector<Vector<String>> getData() throws SQLException {
con = DriverManager.getConnection(...);
statement = con.createStatement();
result = statement.executeQuery("Select * from table");
int c = result.getMetaData().getColumnCount();
while (result.next()) {
Vector<String> newRow = new Vector<String>(c);
for (int i = 1; i <= c; i++) {
newRow.add(result.getString(i));
}
data.add(newRow);
}
return data;
}
public static void main(String[] args) {
System.out.println(String.valueOf(getColumns())); // Error
System.out.println(String.valueOf(getgetData())); // Error
}
}
How println
vectors?
....................................................................................................................