Ask Experts Questions for FREE Help !
Ask
    usmanwalana's Avatar
    usmanwalana Posts: 1, Reputation: 1
    New Member
     
    #1

    Aug 10, 2014, 04:38 AM
    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.

Check out some similar questions!

1993 honda accord 10th anniversary edition -problem with emc and or fuel problem [ 3 Answers ]

Thank you for your quick response and research in helping me with my problem that I posted yesterday.I am having a hard time trying to understand what is going on with my car. History of the car: purchased in 1996 with 59,372 miles, now have 132,000 miles and it has all original factory parts...

What is the need of jdbc [ 1 Answers ]

Jsp with jdbc connection [ 1 Answers ]

Hi... How to store and retrieve employee form with jsp and jdbc connection.

1995 Altima Idleing problem Knock & O2 sensor, EGR Flow Problem [ 1 Answers ]

I have 1995 Nissan Altima with 67,000 miles. When the car is idleing when I start it or when it is at a red light the rpm's go from 6000 to 9000. It sounds like I am reving the engine. The engine sounds fine when I am driving the car ( rpm's are consitent). I went to AutoZone the read out errors...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.