Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to load username from database in ComboBox created in SceneBuilder

 
sakib shaikh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the UserController.java class.


This is the UserModelItem.java.class


This is the initialize method in UserController.java.class


This fillComboBox() function is assigned to ComboBox with fx:id combo via SceneBuilder along with the UserController class.


This is the function to convert ObservableList to String-


i have used 'combobox.setItems(options)' in initialize method in the controller class and i see no error anywhere in the code. but still the combobox is empty when i run the scene. I can mail the entire project if anyone wants to check where i am going wrong. Please help.
 
Paul Clapham
Sheriff
Posts: 21945
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think your JDBC code is right.



Here you select a column named "username".



Here you try to use a column named "username2". This should throw an exception. Have you looked at the place where stderr gets written to? There should be a stack trace there.
 
Paul Clapham
Sheriff
Posts: 21945
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, welcome to the Ranch!
 
sakib shaikh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:And, welcome to the Ranch!


Hi Paul I have edited the code as you suggested and have altered the code a bit but the problem still exists. Can you check again where i am going wrong. Thanks
 
Paul Clapham
Sheriff
Posts: 21945
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now your task is just ordinary JDBC debugging. Like, was an exception thrown? (Hint: look for the stack trace wherever System.err gets written.) Is that while-loop ever entered? If so what's the value of the field read from the database. Maybe the method is never even called?

I have no idea whether any of those ideas is the problem. But you can't solve everything by just looking at the code. Start debugging now.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!