Java tutorial
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; public class Main { public static void main(String[] argv) throws Exception { Connection con = null; PreparedStatement prepstmt = con.prepareStatement("select Name, Addr from Employee where Id = ?"); prepstmt.setString(1, "1"); ResultSet rs; rs = prepstmt.executeQuery(); boolean found = rs.next(); if (found) System.out.println(rs.getString(1)); prepstmt.close(); } }