• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Scene not displaying 2 database fields

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this project for class and my OCD is in overdrive right now. I can't stand moving on to another piece of code when the part I'm working on isn't fully functional. For the life of me though, I can't figure out why first_name and last_name won't display in the report scene I created when I run the program.

Screenshot:


This is the code I have for the scene, DB file, and the Customer.java file.
Scene:


My DB file:


And my Customer.java file:
 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your attributes (first_name and last_name) do not follow standard naming conventions, which means your getters for those two don't either.

They should be called firstName and lastName.

At the moment I suspect that the column mapping for the property is looking for getFirst_name and getLast_name methods.

 
Steven Moore
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:Your attributes (first_name and last_name) do not follow standard naming conventions, which means your getters for those two don't either.

They should be called firstName and lastName.

At the moment I suspect that the column mapping for the property is looking for getFirst_name and getLast_name methods.



Since I'm not allowed to change how they are in the database per my professor, then I'm stuck between a rock and a hard place. On the database table, I created, I follow standard naming conventions. I have 15+ years with MySQL and have followed those standards since I first started with MySQL. My professor however is a numb skull that shouldn't be teaching this course, let alone teaching at all.

Anyway, the column mapping is above, I didn't have it that way but I changed it and still no luck with the names displaying.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have to change the column names in the DB, you have to change either the variable name to firstName and lastName or change these methods in Customer...
...to be getFirst_name(), getLast_name, etc.  Naming conventions are very important in JavaFX.  See NamingConventions (that' s link).
 
Steven Moore
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much, I didn't realize how strict naming conventions are in JavaFX.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are actually stricter than that, although I think you can do things the way you have them setup.  If you are creating a JavaFX bean, you would use properties as the fields and provide two kinds of accessors and an optional setter.  It would look like this:
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steven Moore wrote:Thanks so much, I didn't realize how strict naming conventions are in JavaFX.



It's not JavaFX per se, it's the definition of a Java Bean.

If a bean attribute is called "someAttribute" then the getter for that will be getSomeAttribute, capitalising the first letter of the attribute.

You have told JavaFX here:


that the cell value comes from a property called first_name, so (based on Java Bean standards) it will look for a getFirst_name method.

You could just change that value to firstName, so it then looks for a getFirstName method.
 
reply
    Bookmark Topic Watch Topic
  • New Topic