Assumptions
- Virtual Ubuntu box is reachable (IE. Network)
- MySQL setup is running correctly
- Root password is available!
Let’s get started | Download jdbc connector
Go ahead and get the jdbc connector here or just run the following command
Setup database and tables
Log in to MySQL with root
Now let’s create a database called java, and a table called javaTable for this example, will just store the first name, last name and set a primary key to the id.
User authentication
For best practice let’s create a user, that will only be able to interact with the java database and give all privileges.
- Username: javaUser
- Password: oHeyJava
Now that we have a new user let’s log in with those credentials
Now let’s make sure that the database and tables are viewable
Setting up connection on Mac OSX Maverick 10.9 with netbeans
Now that the virtual server is up and running let’s setup netbeans with a new project and call it javaCRUD
Now right click on the project and go to the properties then libraries
Now click on add library select MySQL JDBC Driver click on add to library, click on ok
Now that it’s setup lets write some code
Having network issues?
Wrapping it up
Now at this point, compile and run the class.
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More