...
- Install the MySQL server.
- Download the JDBC driver for MySQL from here and copy it to your
<EI_HOME>/lib
directory. - Create the following database:
trainingdb
Create the following table:
Code Block CREATE TABLE ACCOUNT(AccountID int NOT NULL,Branch varchar(255) NOT NULL, AccountNumber varchar(255),AccountType ENUM('CURRENT', 'SAVINGS') NOT NULL, Balance FLOAT,ModifiedDate DATE,PRIMARY KEY (AccountID));
Enter the following data into the table:
Code Block INSERT INTO ACCOUNT VALUES (1,"AOB","A00012","CURRENT",231221,'2014-12-02');
...
Anchor | ||||
---|---|---|---|---|
|
Follow the steps given below.
Log in to the management console and select Create under Data Service.
In the Create Data Service screen, enter RDBMS as the data service name. Click Next.
When you get to the Add New Data Source screen, enter the following details:
Datasource ID : AccountDetails
Datasource type: RDBMS
Database Engine: Select MySQL
URL : jdbc:mysql://localhost:3306/trainingdb
Field Value Datasource ID AccountDetails Datasource type RDBMS Database Engine Select MySQL URL jdbc:mysql://localhost:3306/trainingdb User Name root Password (Leave this field blank) Info If you enter External instead of the Default datasource type, your datasource should be supported by an external provider class, such as
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.
You can select the External option and enter the name and value of connection properties by clicking Add Property. For example,
After an external datasource is created, it can be used as a usual datasource in queries. See the tutorial on handling distributed transactions for more information on using external datasources.Note Be sure to download the JDBC driver for MySQL from here and copy it to your
<EI_HOME>/lib
directory.If the driver class does not exist in the relevant folders when you create the datasource, you will get an exception such as 'Cannot load JDBC driver class com.mysql.jdbc.Driver'.
- Enter the URL to your MySQL database in the URL field.
- Enter the username and password to connect to your MySQL database. By default the username is root and the password is blank.
Click Save and then Next to start defining a query.
...