I'm trying to convert some data that comes from DB into an Array, using ResultSet to select DB data. In the code below it does not give any error though. If I try to use one:
System.out.println (x [0]);
It does not show the first data, so it looks like the conversion was not done, I wanted to know if that's the way it converts, or if it can not be done within the while.
public static void main(String[] args) {
connection = new Conexao().getConnection();
String sql = "SELECT * FROM figura";
try {
PreparedStatement ps = connection.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while(rs.next()){
String x = rs.getString(2);
String y = rs.getString(3);
x.toCharArray();
y.toCharArray();
System.out.println(x);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}