#Install
- Open gitbash
- Change directory to a directory you want the project to be located in
- git clone https://github.com/RobinGulbrandsen/MyFirstDatabaseConnection.git
- Open Eclipse
- Right Click the Project Explorer view
- Import
- Import...
- Existing Java Project into Workspace, Next
- Click Browse
- Navigate to the location of the project where you downloaded and select MyFirstDatabaseConnection
- Finish
- Right click the project and select Properties (Alt + Enter)
- Select Java Build Path
- Select the tab "Libraries"
- Click the button Add External Jar...
- In the project, open the "lib" folder and select the file "mysql-connector-java-5.1.18-bin"
- Run the program as you use to
- Edit SQL login credentials by editing databaseName, username and password in no.app.controller.DatabaseConnection
We require a MySQL server to be running to be able to connect to this. I would recommend WAMP server for windows users and MAMP for mac users.
- Start your local database server
- Create a database called "test"
- Create a table called "person"
- the person table needs two collumns, "username" and "password"
- insert test data in the table
CREATE TABLE person (
username varchar(20),
password varchar(20)
);
INSERT INTO person VALUES('Joker', '1234');
INSERT INTO person VALUES('Catwoman', '1234');
- Right click the project
- Run As
- Select Java Application
- Select Client - no.app.view
#INFO
The application follows a simple MVP pattern for CRUD at a database.
Happy hacking!