-
-
Notifications
You must be signed in to change notification settings - Fork 26
Guide Step 2 DB Model
This step describe how to create a new model from an existing database.
Before continuing ensure your home directory is defined and the project has been initialized.
Edit the databases.dbcfg XML file to define a new database configuration.
Launch the external editor with the edb (Edit DB) command in Telosys-CLI or if you are in your prefered editor (Atom, VSCode, etc) just open the databases.dbcfg file.
In databases.dbcfg add a new <db> tag with all the expected information (use the examples of databases configuration available in the commented lines of the file).
For each database you must define the following attributes :
-
idan integer that identifies the database (from 0 to N) -
namethe database name (just for information, you can use any name) -
driverthe JDBC driver class name -
urlthe JDBC URL to access the database
If you plan to generate code for JPA you can also define :
-
typeNamethe type of database (eg "POSTGRESQL", "DERBY", "H2", "ORACLE", etc) -
dialectthe JPA dialect (eg "org.hibernate.dialect.MySQLDialect")
Set the following JDBC properties ( in a <property> tag ) :
- property name
userthe database user - property name
passwordthe database user's password - if necessary you can define any other JDBC specific properties required by your database
Define the following information used to retrieve the JDBC METADATA ( in the <metadata> tag ):
-
catalogthe database catalog to be used if any ("" for void, "!" for null) -
schemathe database schema containing the tables you want to use ("" for void, "!" for null) -
table-name-patternthe pattern to filter the tables names (eg "%" for all tables ) -
table-typesthe type of tables to be used (eg "TABLE VIEW", "TABLE", "VIEW") -
table-name-excludea pattern to exclude some tables (usually void) -
table-name-includea pattern to include some tables (usually void)
To see all databases currently defined you can use the ldb command (List DB)
Telosys needs a JDBC driver to be able to connect to the database.
So put the ".jar" file containing the JDBC driver class in the "lib" folder.
For example, for a "Derby" database put the "derbylient.jar" in "TelosysTools/lib".
Once the database is defined in the databases.dbcfg file and its driver .jar file is available in the "lib" folder you can check the connection.
To check the connection use the cdb command (Check DB)
You can use cdb with or without the database id :
-
cdbwithout argument will check the default database -
cdb 2with argument "2" will check the database with id "2"
Once you have validated the connection to the database you are ready to generate the model.
To create a new "db model" use the ndbm command (New DB Model)
You can use ndbm with or without the database id :
-
ndbmwithout argument will create a model from the default database -
ndbm 2with argument "2" will create a model from the database with id "2"
-
edbEdit DB -
ldbList DB -
cdbCheck DB -
ndbmNew DB Model
Use ? command-name to get help
- Installation
- Configuration
- Commands
- User guide :
- Project initialization
- Model initialization :
- Templates
- Code generation