Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Search customer by ID

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know why my code is not working at all. In my Eclipse there's no errors shown at all.

I want to use the id to print the name of my customers, and that's my goal



 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the code you posted doesn't print anything. Perhaps there's some other code which you didn't show us, and it's supposed to be printing something?

The only thing I can see which is not quite self-explanatory is the array of Customers called custArray. The method you posted ignores that array and searches something else which is called customers.
 
James Teter
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the code all I have.
 
Paul Clapham
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, there you go then. There's nothing which calls that method so you shouldn't be surprised that it never gets run and never prints anything. (Not that it would print anything even if it did get run.)

Perhaps there's something else that you didn't tell us about? Some framework which somebody else is going to use to run your code, perhaps?
 
Sheriff
Posts: 3102
459
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Teter wrote:I dont know why my code is not working at all. In my Eclipse there's no errors shown at all.


When I put you code in Eclipse, I see something like this (I changed the line numbers to agree with what you have posted):
 
Ron McLeod
Sheriff
Posts: 3102
459
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Teter wrote:That's the code all I have.


Do you have that code inside a class?

Do you have a class named Customer?
 
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't replicated the code but I think that the method is not using custArray properly, please have a look at this code, it is using custArray;




On the other hand, you need to have a class called Customer with a member "ID". Then in order to call the method "searchCustomerByID" maybe the best is to write a run method as explained on this https://coderanch.com/wiki/660020/Main-Pain post.
 
I don't always make ads but when I do they're tiny
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic