This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Connection Not Working

 
Mike London
Ranch Hand
Posts: 1216
6
  • 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
 
Paul Clapham
Sheriff
Posts: 21546
33
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
Ranch Hand
Posts: 1216
6
  • 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
Sheriff
Posts: 21546
33
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
Ranch Hand
Posts: 1216
6
  • 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.


:)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic