usmanwalana
Aug 10, 2014, 04:38 AM
Having trouble in setting first perimeter using prepared statement
I am working on jdbc connected to mysql database
here is the code :
PreparedStatement viewById = null;
Scanner input = new Scanner(System.in);
System.out.println("Enter Id : ");
int id = input.nextInt();
try (
Connection connection = DBUtil.getConnection();
Statement statement = connection.createStatement();
)
{
String sql = ("SELECT id , date, place, quantity FROM stocks WHERE id=?");
viewById = connection.prepareStatement(sql);
viewById.setInt(1, id);
the error is showing on (1,id) that cannot resolve query parameter
I am new to this so please be patient.
I am working on jdbc connected to mysql database
here is the code :
PreparedStatement viewById = null;
Scanner input = new Scanner(System.in);
System.out.println("Enter Id : ");
int id = input.nextInt();
try (
Connection connection = DBUtil.getConnection();
Statement statement = connection.createStatement();
)
{
String sql = ("SELECT id , date, place, quantity FROM stocks WHERE id=?");
viewById = connection.prepareStatement(sql);
viewById.setInt(1, id);
the error is showing on (1,id) that cannot resolve query parameter
I am new to this so please be patient.