Java - Select Statament - My SQL



String[] names = new String[100];
Connection con = getConnection();
String query = "SELECT name FROM student";
PreparedStatement preparedStatement = con.prepareStatement(query);

ResultSet resultSet = preparedStatement.executeQuery();

int i=0;
while(resultSet.next()) {
       names[i] = resultSet.getString("name"); // name is the field name
       i++;
}

Post a Comment

0 Comments