Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
src
LICENSE
README.md
dataaccessagility-java-sample-code-01.iml

README.md

Data Access Agility Java Sample Code

This project shows you how Data Access Agility could make database manipulation much easier.

Getting Started

Code files in the folders src/models and src/dataaccessobjects have been auto generated by Data Access Agility. Please have a look at the entry class (DataAccessAgilityJavaSampleCode) to see how we make calls to a database using the auto generated classes. The sample code assumes that the back-end database is MySql. Do not forget to include your database parameters in the connection string.

Prerequisites

Make sure to install MySql JDBC Driver (MySql Connector for Java). Driver version shall be compatible with Java SDK version used in the project

Running the Project

Before you can run the project, execute the following SQL script on the target database. This script has also been generated by Data Access Agility. Please note that this script is compatible with MySql Server only. To test the project against a different database engine, such as Oracle and MS Sql Server, please create a project at http://www.dataaccessagility.com and select whatever database engine you want.

-- HR_EMPLOYEE
CREATE TABLE HR_EMPLOYEE(
EMP_ID INT NOT NULL,
EMP_NO VARCHAR(16) NOT NULL,
EMP_FULL_NAME VARCHAR(128) NOT NULL,
EMP_Gender INT NULL,
EMP_HIR_DATE DATE NULL,
EMP_STATUS INT NOT NULL,
EMP_TYPE INT NOT NULL,
EMP_SALARY DECIMAL(10, 2) NOT NULL,
EMP_DIVISION_ID INT NOT NULL,
EMP_PICTURE VARBINARY(2048) NULL,
EMP_LATEST_CI_DT DATETIME NOT NULL
);

-- HR_DIVISION
CREATE TABLE HR_DIVISION(
DIVISION_ID INT NOT NULL,
DIVISION_PARENT_ID INT NULL,
DIVISION_NAME VARCHAR(64) NOT NULL
);

-- TBL_SAMPLE
CREATE TABLE TBL_SAMPLE(
SA VARCHAR(123) NOT NULL,
dadsa DATETIME NOT NULL
);

-- PK_HR_EMPLOYEE_EMP_ID
ALTER TABLE HR_EMPLOYEE
ADD CONSTRAINT PK_HR_EMPLOYEE PRIMARY KEY (EMP_ID ASC);

-- UQ_HR_EMPLOYEE_EMP_NO
ALTER TABLE HR_EMPLOYEE
ADD CONSTRAINT UQ_HR_EMPLOYEE_EMP_NO UNIQUE (EMP_NO ASC);

-- PK_HR_DIVISION_DIVISION_ID
ALTER TABLE HR_DIVISION
ADD CONSTRAINT PK_HR_DIVISION PRIMARY KEY (DIVISION_ID ASC);

-- FK_HR_EMPLOYEE_EMP_DIVISION904
ALTER TABLE HR_EMPLOYEE
ADD CONSTRAINT FK_HR_EMPLOYEE_EMP_DIVISION904 FOREIGN KEY (EMP_DIVISION_ID) REFERENCES HR_DIVISION (DIVISION_ID) ON DELETE NO ACTION ON UPDATE NO ACTION;


After you execute this script, specify the connection string of the target database in the main method:

ConnectionProvider.setConnectionString("jdbc:mysql://DATABASE_HOST?allowMultiQueries=true", "db_username", "db_password");

License

This project is licensed under the MIT License - see the LICENSE.md file for details

You can’t perform that action at this time.