Saturday, March 5, 2011

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++;
}

0 comments:

Post a Comment

Contact Form

Name

Email *

Message *

The Insane Techie - Android App

Launched an android app for the blog on 07th June 2016. Get it from google play store... Tips for using the app Use in landscape mo...