Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Problem in jdbc (https://www.askmehelpdesk.com/showthread.php?t=798855)

  • Aug 10, 2014, 04:38 AM
    usmanwalana
    Problem in jdbc
    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.

  • All times are GMT -7. The time now is 10:10 PM.