Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Simple Connection Not Working

 
Bartender
Posts: 1757
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a simple SQL statement to execute in a loop to see if a PK exists.

My Connection is fine, all values resolve (no compile errors). The mySQLConnection Connection is used in the same class and connects without issues to MySQL.

Here's the connection:

final PreparedStatement lookUpPKInMySQLCustomer = mySQLConnection.prepareStatement("SELECT COUNT(CUS_PK) as count from Customer where CUS_PK=?");

No error on the line above. In the debugger I have a connection object, as expected, with ParameterCount = 1.

Yet, when I, in the same method, try to set the first query param, like this:

theInt = getIntCode();
lookUpPKInMySQLCustomer.setInt(1, theInt);

It says that it cannot resolve query parameter 1.

Huh?

The actual customer table indeed does have a CUS_PK and it is indeed an Int.

I'm clearly missing something ridiculously obvious...

Thanks in advance.

-mike
 
Marshal
Posts: 25814
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike London wrote:It says that it cannot resolve query parameter 1.



Who said that, and exactly what words did it use to say it? (Paraphrased versions of error messages are less helpful, even less when we don't know whose error message it is.)
 
Mike London
Bartender
Posts: 1757
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Mike London wrote:It says that it cannot resolve query parameter 1.



Who said that, and exactly what words did it use to say it? (Paraphrased versions of error messages are less helpful, even less when we don't know whose error message it is.)



Paul,

Thanks for the quote-back, but that was my exact question (I didn't miss the error message...) given the code it SHOULD have resolved it, right? I had a single "?" and tried to set the single parameter. Hence the question.

In any case, the problem just went away. Must have been a caching or other temporary problem.

Appreciate your response.

Thanks,

-mike
 
Paul Clapham
Marshal
Posts: 25814
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whatever "it" was, sure... but anyway, the problem's gone away and that's a good thing.
 
Mike London
Bartender
Posts: 1757
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Whatever "it" was, sure... but anyway, the problem's gone away and that's a good thing.



:)
 
Get me the mayor's office! I need to tell her about this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic