Skip to content
Advertisement

I’m using JavaFX and my combobox doesn’t want to populate from an sql database

What I’m trying to do is have my combobox get populated with AgentID’s from my travelexperts database when the app loads.

I think the problem is somewhere in the controller class. I don’t get any exceptions but if I try to run the buildCombo() method from one of the buttons instead of initialize I get a class not found exception

Controller class:

DB class:

Main Class:

Sample class:

Agent Class:

Advertisement

Answer

In your DB Class you are using the right MySQL Driver but in your buildCombo() Method you are using wrong/deprecated driver for MySQL, change Class.forName("com.mysql.cj.jdbc.Driver"); to Class.forName("com.mysql.jdbc.Driver"); as you have in DB Class and it should work. Also, print out the ResultSet rs in the console, so you are sure that you are having some result there.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement