A presentation about Developing Applications with MySQL and Java for beginners. It includes the following topics:
- Requirements
- MySQL Data Definitions
- Java Classes
- MySQL Connector (JDBC)
- Define Methods
- Compile and Run
2. Please Please Please
Ask Questions
As Much As You Like
• This is not a lecture!
- But an opportunity to learn
from each other.
- If you haven’t seen some of
these frameworks, methods,
etc. It is OK!
- Let we know if you know
‣ Better ways
‣ Best practices
‣ My mistakes!
3. Requirements
• Java (OpenJDK)
• MySQL
• MySQL Connector
- JDBC (Java Database Connectivity)
‣ https://dev.mysql.com/downloads/connector/j/
• Text Editor
• Command Line!
3
4. MySQL Data Definition
• Create database
- $ mysql -u root -p
‣ mysql> CREATE DATABASE phonebook_app;
• Create database user
- $ mysql -u root -p
‣ mysql> GRANT ALL PRIVILEGES on `phonebook_app`.* to `pb_app`@'127.0.0.1' identified by '123456';
• Create table
- $ mysql -u pb_app -p phonebook_app
‣ mysql> CREATE TABLE `contact` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(100),
`last_name` VARCHAR(100),
`email` VARCHAR(100),
`mobile` VARCHAR(15),
PRIMARY KEY (`id`)
);
4
5. Java Classes
Contact
• Contact
- Fields
‣ long id
‣ String firstName
‣ String lastName
‣ String email
‣ String mobile
- Methods
‣ Contact()
‣ Getters for all fields: getId(), getFirstName() and etc.
5
16. Read The F* Manual
• RTFM
- https://dev.mysql.com/doc/
- http://docs.oracle.com/javase/
• Java: The Really Big Index
- http://docs.oracle.com/javase/tutorial/reallybigindex.html
• MySQL Help
- mysql> HELP;
- mysql> HELP CONTENTS;
- mysql> HELP SELECT;
16