Reputation: 23
I am working on an app in NetBeans for a class and need the GUI to be able to communicate to a database that I created in Microsoft SQL Server Management Studio. The GUI need to be able to take user information and import it to the database. It also needs to be able to retrieve information from the database for review and editing purposes. I have never used the database before, but was able to teach myself the basics. I am having trouble finding out how to connect the GUI to my database though. Is there an easy way to connect the two? I don't mind learning myself, in fact that would be preferable, but any links or suggestions would be very much appreciated.
Upvotes: 1
Views: 23873
Reputation: 7008
There is a tutorial here for connecting to a MySQL database:
https://netbeans.org/kb/docs/ide/mysql.html
Almost everything will be the same with Microsoft, except you will need a different JDBC driver. You might want to practice with MySQL first since it is free. The MySQL driver comes with Netbeans but the Microsoft Driver will need to be downloaded separately. I believe you can get at the following, but I haven't tried it.
https://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx
You add drivers to Netbeans by going to the Services Tab, Right-click on Databases -> New Connection and click the Add button in the dialog.
You will also need to add the driver to each projects libraries.
The general JDBC tutorial is here:
https://docs.oracle.com/javase/tutorial/jdbc/
which covers the common interface between databases.
It is not necessary but it can be useful and or easier to do beans binding between Gui and database.
See this tutorial:
https://netbeans.org/kb/docs/java/gui-binding.html
Upvotes: 2