Creación de la base de datosCrear únicamente la base de datos sobre el SGBD elegido; el conjunto del esquema (tablas, claves primarias, triggers…) se creará posteriormente de manera automática en un primer despliegue, en el momento que la aplicación reconoce que no existe. El proceso va a variar ligeramente:
- Para Oracle: En este caso el acceso y creación del esquema es por usuario. Así que será suficiente con crear un usuario para este fin con los suficientes privilegios. Este usuario será el que se indique en el fichero de configuración server.xml del Tomcat. Por ejemplo, en el caso de que el usuario fuese DashboardSII:
DataBase Creation | Create only the database on the chosen DBMS; The schema set (tables, primary keys, triggers ...) will be created automatically later on a first deployment, at a time when the application recognizes that it does not exist. The process will vary slightly: - For Oracle: In this case the access and creation of the schema is per user. So it will be sufficient to create a user for this purpose with sufficient privileges. This user will be indicated in the Tomcat server.xml configuration file. For example, in case the user is DashboardSII:
CREATE USER DASHBOARDSII IDENTIFIED BY DASHBOARDSII; |
- Para SqlServer: Se creará un esquema con el nombre de base de datos definido en la conexión. Por ejemplo, en el caso de que la base de datos se llamase sii:
- For SqlServer: A schema with the database name defined in the connection will be created. For example, in the event that the database is called sii:
CREATE DATABASE sii […]; |
- Para MySql: Igual que en el caso de SqlServer se creará un esquema con el nombre DashboardSII:
- For MySql: Just as in the case of Sql Server will create a scheme with the name DashboardSII:
CREATE SCHEMA DashboardSII; |
2. |
Configuración del fichero de propiedades Configuration of the SIIDashboard.properties |
Se copia el fichero de propiedades utilizado por el dashboard en la ruta que se desee.
Una buena elección sería el directorio de configuración del servidor; en el caso de Apache Tomcat, el directorio ‘/conf’. Aunque podría ser en cualquier otro sitio. La ruta donde se guarde la utilizaremos más adelante para dar valor a una variable de entorno que utilizará la aplicación para recuperar el identificador del tenant.
Por lo tanto, este fichero de propiedades tendrá básicamente una única propiedad.
property file | It copies the properties file used by the dashboard in the desired path. A good choice would be the server's configuration folder; In the case of Apache Tomcat, the '/ conf' folder. Although it could be anywhere else. The path where it is saved will be used later to give value to an environment variable that the application will use to retrieve the identifier of the tenant. Therefore, this property file will basically have a single property.
|
3. |
Configuración de la conexión con la base de datos dentro del contenedor Web Se deben configurar un par de elementos a nivel del servidor. Aunque la manera concreta de hacer esta configuración dependerá del servidor elegido, utilizaremos como ejemplo de referencia el servidor Apache Tomcat, por ser el servidor sobre el que se ha desarrollado y probado la solución.
| Nombre del recurso JNDI: jdbc/SIIOracle
Para Apache Tomcat, en el fichero ‘server.xml’, dentro del bloque <GlobalNamingResources> se añade un nuevo tag <Resource> con los datos de conexión a la base de datos.
Configuring the connection to the database | The configuration of the connection to the database (url, user, password, driver...), can be done either through the web container itself or through the properties file of the application.
|
| Although the specific way to do this configuration will depend on the chosen server, we will use as a reference example the Apache Tomcat server, because it is the server on which the solution has been developed and tested. The specific configuration will depend on the database engine used (Oracle, SqlServer or MySql). For each of them, a separate connection pool will be defined; one for the web appliance and SOAP services, and another for the alarm engine. |
| Name of the exclusive JNDI resource for the web part and the SOAP services: jdbc/SIIOracle Exclusive JNDI resource name for the alarm engine: jdbc/SIIOracleScheduler For Apache Tomcat, in the file 'server.xml', within the <GlobalNamingResources> block, a new <Resource> tag is added with the connection data to the database.
<Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" |
|
factory="org.apache.tomcat.dbcp.dbcp2. |
|
BasicDataSourceFactor yBasicDataSourceFactory" maxActive="200" maxIdle="200" maxWait="-1" |
|
name="jdbc/SIIOracle" password="*****" testOnBorrow="true" type="javax.sql.DataSource" |
|
Para Apache Tomcat, en el fichero ‘context.xml’ creamos una nueva entrada <ResourceLink> dentro del bloque <Context> para referenciar la conexión a la base de datos declarada anteriormente en el fichero ‘server.xml’ url="jdbc:oracle:thin:@//***.**.*.**:****/****" username="*******" validationQuery="select 1 from dual" validationQueryTimeout="5"/> |
|
<Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" factory="org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory" maxActive="200" maxIdle="200" maxWait="-1" name="jdbc/SIIOracleScheduler" password="*****" testOnBorrow="true" type="javax.sql.DataSource" url="jdbc:oracle:thin:@//***.**.*.**:****/****" username="*******" validationQuery="select 1 from dual" validationQueryTimeout="5"/> |
For Apache Tomcat, in the 'context.xml' file we create a new <ResourceLink> entry inside the <Context> block to reference the connection to the database previously declared in the file 'server.xml'.
<ResourceLink global="jdbc/SIIOracle" name="jdbc/SIIOracle" type="javax.sql.DataSource"/> |
|
Si nos fijamos el valor para los atributos “global” y “name” coinciden con el nombre dado al recurso que creamos anteriormente.
Copiamos en el directorio ‘/lib’, en caso de que no exista, la librería Java de conexión a <ResourceLink global="jdbc/SIIOracleScheduler" name="jdbc/SIIOracleScheduler" type="javax.sql.DataSource"/> |
If we set the value for the attributes "global" and "name" match the name given to the resource we created earlier. Copy in the '/ lib' directory, if it does not exist, the Java connection library to Oracle: ojdbc7.jar |
|
Nombre del recurso JNDIName of the exclusive JNDI resource for the web part and the SOAP services: jdbc/SIISqlserver |
Para Exclusive JNDI resource name for the alarm engine: jdbc/SIISqlserverScheduler For Apache Tomcat, |
en el fichero ‘server.xml’, dentro del bloque <GlobalNamingResources> se añade un nuevo tag <Resource> con los datos de conexión a la base de datosin the'server.xml' file, within the <GlobalNamingResources> block, a new <Resource> tag is added with the connection data to the.er database. <Resource auth="Container" driverClassName="com.microsoft.sqlserver.jdbc |
|
.SQLServerDrive r.SQLServerDriver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="30" maxActive=" |
|
200200 maxOpenPreparedStatementsminEvictableIdleTimeMillis=" |
|
100 maxWait-150" name="jdbc/SIISqlserver" password= |
|
"u2r_da2hb0ard" poolPreparedStatements"*******" removeAbandoned="true" removeAbandonedTimeout="300" testOnBorrow="true" timeBetweenEvictionRunsMillis="30000" type="javax.sql.DataSource" url="jdbc:sqlserver://***.**.**.**:****;databaseName=**;user=*******;password=*******;" username="*******" validationInterval="40000" validationQuery="SELECT 1"/> <Resource auth="Container" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="30" maxActive="300" maxIdle="250" minEvictableIdleTimeMillis="60000" minIdle="50" name="jdbc/SIISqlserverScheduler" password="*******" removeAbandoned="true" removeAbandonedTimeout="300" testOnBorrow="true" timeBetweenEvictionRunsMillis="30000" type="javax.sql.DataSource" url="jdbc:sqlserver://***.**.**.**:****;databaseName=**;user=*******;password=*******;" username="*******" validationInterval="40000" validationQuery=" |
|
select > Para en el fichero ‘context.xml’ creamos una nueva entrada <ResourceLink> dentro del bloque <Context> para referenciar la conexión a la base de datos declarada anteriormente en el fichero ‘server.xml’. in the 'context.xml' file we create a new <ResourceLink> entry inside the <Context> block to reference the connection to the database previously declared in the file 'server.xml'. <ResourceLink global="jdbc/SIISqlserver" name="jdbc/SIISqlserver" type="javax.sql.DataSource"/> <ResourceLink global=" |
|
/> Si nos fijamos el valor para los atributos “global” y “name” coinciden con el nombre dado al recurso que creamos anteriormente.
Copiamos en el directorio ‘/lib’, en caso de que no exista, la librería Java de conexión a jdbc/SIISqlserverScheduler" name="jdbc/SIISqlserverScheduler" type="javax.sql.DataSource"/> |
If we set the value for the attributes "global" and "name" match the name given to the resource we created earlier. We copy in the directory '/lib', in case it does not exist, the Java library of connection to SqlServer: sqljdbc4-6.0. |
jar Nombre del recurso JNDIName of the exclusive JNDI resource for the web part and the SOAP services: jdbc/SIIMySQL |
Para Exclusive JNDI resource name for the alarm engine: jdbc/SIIMySQLScheduler For Apache Tomcat, |
en el fichero ‘server.xml’, dentro del bloque <GlobalNamingResources> se añade un nuevo tag <Resource> con los datos de conexión a la base de datos.
<Resource a new <GlobalNamingResources> tag with the database connection data is added to the <GlobalNamingResources> block in the'server.xml' file. <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="30" maxActive=" |
|
200200" maxWait250" minEvictableIdleTimeMillis="60000" minIdle=" |
|
-150" name="jdbc/SIIMySQL" password="******* |
|
" poolPreparedStatements" removeAbandoned="true" removeAbandonedTimeout="300" testOnBorrow="true" timeBetweenEvictionRunsMillis="30000" type="javax.sql.DataSource" url="jdbc:mysql://***.***.**.**:***/DashboardSII" username="*******" validationInterval="40000" validationQuery="SELECT 1"/> <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" initialSize="30" maxActive="300" maxIdle="250" minEvictableIdleTimeMillis="60000" minIdle="50" name="jdbc/SIIMySQLScheduler" password="*******" removeAbandoned="true" removeAbandonedTimeout="300" testOnBorrow="true" timeBetweenEvictionRunsMillis="30000" type="javax.sql.DataSource" url="jdbc:mysql://***.***.**.**:***/DashboardSII" username="*******" validationInterval="40000" validationQuery=" |
|
rootPara
en el fichero ‘context.xml’ creamos una nueva entrada <ResourceLink> dentro del bloque <Context> para referenciar la conexión a la base de datos declarada anteriormente en el fichero ‘server.xml’in the 'context.xml' file we create a new <ResourceLink> entry inside the <Context> block to reference the connection to the database previously declared in the file 'server.xml'. <ResourceLink global="jdbc/SIIMySQL" name="jdbc/SIIMySQL" type="javax.sql.DataSource"/> <ResourceLink global="jdbc/SIIMySQLScheduler" name="jdbc/SIIMySQLScheduler" type="javax.sql.DataSource"/ |
|
> Si nos fijamos el valor para los atributos “global” y “name” coinciden con el nombre dado al recurso que creamos anteriormente.
Copiamos en el directorio ‘/lib’, en caso de que no exista, la librería Java de conexión a If we set the value for the attributes "global" and "name" match the name given to the resource we created earlier. Copy to the '/ lib' folder, if it does not exist, the Java library connecting to SqlServer: mysql-connector-java-5.1.42. |
jar 4. Declaración de la ruta al fichero de propiedades | Creamos una variable de entorno con la ruta donde se encuentra el fichero de propiedades ‘SII-Dashboard.properties’ que hemos copiado anteriormente.
Para Apache Tomcat, en el fichero context.xml se define una nueva entrada <Environment> dentro del bloque <Context>
5. Declaración del perfil de BD | En el fichero de configuración ‘context.xml’ de Apache Tomcat, se define una nueva variable para indicar el perfil utilizado de acuerdo con la base de datos.
Para Oraclejar |
- Through the properties file
| Alternatively, you can define the database connection data via the 'SII-Dashboard.properties' property file. In this case the properties to be specified are: - datasource.url: Url of connection to the BD
- datasource.username: User name of access to the BD
- datasource.password: Password to access the BD
- sii. datasource.driver-class-name: Name of the driver used for the connection (depending on the database engine used)
|
4. Declaration of the path to the properties file | We create an environment variable with the path where the 'SII-Dashboard.properties' property file we have copied previously. For Apache Tomcat, the context.xml file defines a new <Environment> entry within the <Context>
<Environment name="sii-dashboard-props-file-location" override="true" type="java.lang.String" value="D:/apachetomcat-8.0.36/conf/SII-Dashboard.properties"/> |
|
La ruta completa donde está el fichero de propiedades se especifica como valor del atributo “value”
Para The full path where the property file is specified as value of the attribute "value" |
5. BD's profile statement | In the configuration file 'context.xml' of Apache Tomcat, a new variable is defined to indicate the profile used according to the database.
<Environment name="spring.profiles.active" value="oracle" type="java.lang.String"/> |
|
<Environment name="spring.profiles.active" value="sqlserver" type="java.lang.String"/> |
|
Para MySql
<Environment name="spring.profiles.active" value="mysql" type="java.lang.String"/> |
|
6. |
Establecer configuraciones Java en el arranque del servidor de aplicaciones Para Windows, Set Java configurations at startup of the application server | set JAVA_OPTS=-“Dfile.encoding=UTF-8 –Xms256m Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=1024m” |
|
Para , set JAVA_OPTS=-Dfile.encoding=UTF-8 –Xms256m Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=1024m |
|