Hi!
You have decided that you need integration tests in addition to your unit tests. How can we automate integration testing of J2EE code?
Arquillian to rescue! Arquillian is integration testing framework for Java EE. To get started you need an Arquillian library, adapter container, container and test :-).
Is sounds a lot like to configure. Well no so many by hand. For the integration test I have chosen Wildfly 8.2.1. Also I want that Arquillian itself managed starting and stopping of wildfly.
For those who are impatient look into github: https://github.com/chernykhalexander/arquillian_db2_J2EE.git.
The easiest way to add the arquillian in pom.xml is to you jBoss forge tool. Forge is a special utility to manage java projects. Or you can look into pom.xml on github.
This pom also:
1) downloads the wildfly 8.2.1 distribution and expand it into the target directory.
2) copy the IBM DB2 driver into the expanded wildfly
3) uses maven-failsafe-plugin to run integration-tests. It's execution is bounded to integration-test and verify goals. If you need to execute integration test make sure integration test files end with "IT".
How to define the JNDI datasource? This is what wildfly-ds.xml responsible for.
Other interesting part is integration test itself. Again, you can ease the creation of test with forge tool.
When creating the test pay attention to the @deployment method. You need to specify all classes and files your test uses.
After all have been done mvn integration-test and that is all! Happy testing.
This blog is a collection of minds around linux, java, javascript, etc. Looking for great opportunities.
Показаны сообщения с ярлыком DB2. Показать все сообщения
Показаны сообщения с ярлыком DB2. Показать все сообщения
пятница, 4 декабря 2015 г.
вторник, 24 ноября 2015 г.
DB2 CLP. Disable autocommit
To disable autocommit is db2 clp write the following command:
UPDATE COMMAND OPTIONS USING c OFF.
To check the results write the following command:LIST COMMAND OPTIONS
понедельник, 1 июня 2015 г.
DB2 export data tables from remote database
If you have IBM DB2 client and you have to move data from remote source database to local target database then you can use db2 move utility.
First, catalog the node:
1) db2 catalog tcpip node <node_name> remote <server_name> server <port_number>
2) db2 terminate
Second, catalog the database:
3) db2 catalog db <remote_db_name> as <local_alias_db_name> at node <node_name>
4) db2 terminate
Export data:
db2move <db_name> export -sn <schema_name> -aw -u <login> -p <password>
You can move schemas or given tables. See help for db2move.
Before importing tables data in existent tables you should turn off identity constraint else import process fail:
db2 alter table <table_name> alter column <column_name_with_identity> drop identity
Import data:
db2move <db_name> import -u <login> -p <password>
After import restore identity constraint:
db2 ALTER TABLE <table_name> ALTER COLUMN <column_name_with_identity> SET GENERATED AS IDENTITY ( START WITH <count_the_number_yourself> INCREMENT BY 1)
To uncatalog database and node:
db2 uncatalog database <alias-name>
db2 uncatalog node <node_name>
First, catalog the node:
1) db2 catalog tcpip node <node_name> remote <server_name> server <port_number>
2) db2 terminate
Second, catalog the database:
3) db2 catalog db <remote_db_name> as <local_alias_db_name> at node <node_name>
4) db2 terminate
Export data:
db2move <db_name> export -sn <schema_name> -aw -u <login> -p <password>
You can move schemas or given tables. See help for db2move.
Before importing tables data in existent tables you should turn off identity constraint else import process fail:
db2 alter table <table_name> alter column <column_name_with_identity> drop identity
Import data:
db2move <db_name> import -u <login> -p <password>
After import restore identity constraint:
db2 ALTER TABLE <table_name> ALTER COLUMN <column_name_with_identity> SET GENERATED AS IDENTITY ( START WITH <count_the_number_yourself> INCREMENT BY 1)
To uncatalog database and node:
db2 uncatalog database <alias-name>
db2 uncatalog node <node_name>
вторник, 5 мая 2015 г.
Db2 LUW 10.5 JDBC driver properties
Db2 JDBC driver for LUW has a lot of properties. Description one can find on http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_r0052607.html.
One useful property I was needed is "currentSchema" . It specifies the default schema name that is used to qualify unqualified database objects in dynamically prepared SQL statements. The value of this property sets the value in the CURRENT SCHEMA special register on the database server. The schema name is case-sensitive, and must be specified in uppercase characters.
In WebSphere Application Server this properties can be found in "Custom properties" section of the datasource.
One useful property I was needed is "currentSchema" . It specifies the default schema name that is used to qualify unqualified database objects in dynamically prepared SQL statements. The value of this property sets the value in the CURRENT SCHEMA special register on the database server. The schema name is case-sensitive, and must be specified in uppercase characters.
In WebSphere Application Server this properties can be found in "Custom properties" section of the datasource.
четверг, 26 июня 2014 г.
View DB2 version with SQL command
Start from DB2 9.7 developers added the "create or replace" command.
Working from SQL it is possible to get the DB2 version:
Working from SQL it is possible to get the DB2 version:
SELECT service_level, fixpack_num FROM TABLE
(sysproc.env_get_inst_info())
as INSTANCEINFO
понедельник, 26 марта 2012 г.
DB2 8.2. Оптимизация
Добрый вечер,
Сегодня расскажу пару слов об оптимизации СУБД DB2 8.2.
Итак, для начала необходимо проводить следующие процедуры для поддержания СУБД в рабочем состоянии:
1) сбор статистики,
2) реорганизация таблиц и индексов,
3) обновление статистики,
4) ребиндинг хранимых процедур.
Что касается обновления статистики, то в сети можно найти скрипты по сбору статистики в DB2.
То же самое касается и реорганизации данных.
Ребиндинг можно делать с помощью команды db2rbind <имя бд> -l <лог файл> all.
Правда названная выше команда может корректно выполнится если никто не использует хранимые процедуры в настоящий момент, поэтому эту команду необходимо выполнять в оффлайн режиме.
Также, если у нас DB2 стоит на линуксе с ядром серии 2.6, то можно выставить следующие параметры:
Сегодня расскажу пару слов об оптимизации СУБД DB2 8.2.
Итак, для начала необходимо проводить следующие процедуры для поддержания СУБД в рабочем состоянии:
1) сбор статистики,
2) реорганизация таблиц и индексов,
3) обновление статистики,
4) ребиндинг хранимых процедур.
Что касается обновления статистики, то в сети можно найти скрипты по сбору статистики в DB2.
То же самое касается и реорганизации данных.
Ребиндинг можно делать с помощью команды db2rbind <имя бд> -l <лог файл> all.
Правда названная выше команда может корректно выполнится если никто не использует хранимые процедуры в настоящий момент, поэтому эту команду необходимо выполнять в оффлайн режиме.
Также, если у нас DB2 стоит на линуксе с ядром серии 2.6, то можно выставить следующие параметры:
db2set DB2LINUXAIO=true
db2set DB2_SCATTERED_IO=ON
db2set DB2_DIRECT_IO=YES
После выставления параметров необходимо перезапустить db2.
Начиная с версии 9 параметр DB2_DIRECT_IO использовать не рекомендуется.
Также отключить кеширование можно на уровне табличного пространства. Это делается с
помощью команды ALTER TABLESPACE <имя табличного пространства> NO FILE SYSTEM CACHING;
После выполнения команды ALTER TABLESPACe существующие соединения с БД необходимо закрыть,
чтобы новые правила кеширования вступили в силу.
Однако в боевой системе это делать стрёмно - куда проще поменять параметр среды и
рестартовать СУБД.
Это хороший старт для дальнейшей оптимизации БД.
Подписаться на:
Комментарии (Atom)