import java.sql.*;
try {
Connection conn = DriverManager
.getConnection(url, userName, password);
// Connect to the database
// ...
PreparedStatement stmt = conn.prepareStatement(
"SELECT " +
" Language, Percentage " +
"FROM countrylanguage " +
"WHERE " +
" CountryCode = ? AND " +
" Percentage > ?");
stmt.setString(1, "RUS");
stmt.setDouble(2, 0.5);
ResultSet rs = stmt.executeQuery();
// Get all rows
while (rs.next()) {
System.out.println(
rs.getString(1) + ": " + rs.getString(2));
}
conn.close();
}
catch (Exception e) {
e.printStackTrace();
}