Adding Your Own Tables to the Bundled Database

Today, we received a request via our Creator tutorials feedback alias for information on how to add your own tables to Creator's bundled database. As this bundled database is not meant for production, we suggest that you use your own database. You can use any database that provides a JDBC 3.0 compliant driver. (See http://developers.sun.com/product/jdbc/drivers.) Our Creating Database Server Types and Data Sources tutorial gives an example of how to do this using MySQL.

However, if you want to use the IDE's bundled database for prototyping or what have you, here is how to add your own tables to the bundled database.

1. Create the SQL script and save it in a file, for example:

CREATE USER dbuser PASSWORD dbpassword;
drop schema mySchema;
create schema mySchema AUTHORIZATION dbuser;


create table mySchema.category (
    catid char(20) not null,
    locale varchar(10) not null,
    name varchar(80) null,
    description varchar(255) null,
    constraint pk_category primary key (catid, locale)
)
;


INSERT INTO mySchema.category VALUES (
  'ID1', 'en_US', 'Category 1', 'Description of Category 1')
;

2. In the Servers window, scroll to the bottom of the window and check whether the Bundled Database Server is running. If a red badge appears next to the node's icon, then right-click the node and choose Start Bundled Database from the pop-up menu.

3. Create the schema by completing the following steps.

A. In the Servers window, right-click the Data Sources > Order node and choose View Data from the pop-up menu. A Query tab opens in the editing area.

B. In the Query Editor, click the Import File Containing SQL Commands button (the folder icon), navigate to your SQL script, and click Open.

C. In the Query Editor, click the Configure Run Options button (the grid icon). A Run Query Options dialog box opens.

D. Select the ";" (Semicolon) at End of Line radio button.

E. Click Run Query. The IDE runs the SQL script.

F. Close the Query tab.

4. Add the schema as a data source to the IDE by completing the following steps.

A. In the Servers window, right-click Data Sources and choose Add Data Source from the pop-up menu.

B. Choose the bundled database as the Server Type and enter a data source name, user ID, password, and validation table (choose a small table from your schema). For example, using the example script above, you would enter

Data Source Name: MySchema
User ID: dbuser
Password: dbpassword
Database URL: (Leave the default value)
Validation Table: MYSCHEMA.CATEGORY

C. Click Test to verify your settings.

D. Click Add. An entry appears under Data Sources using the name that you entered for the Data Source Name.

Comments:

Post a Comment:
Comments are closed for this entry.
About

divas

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today