Category Archives: Databases

Clone DB2 10g FC23 install to a virtual machine (FC23 or RHEL7)

By | February 8, 2017

I wanted to move my test db2 installation based on a Fedora Core 23 to a RHEL7 virtual machine without having to reinstall everything and not lose any data. This is in fact cloning my test environment database. This is not an easy task as is not officially supported by IBM but the beauty of… Read More »

DB2: Find a foreign key

By | February 8, 2017

Sometimes working with Hibernate you get the following error in case a persist is executed on an object with dependencies. com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException: Error for batch element #1: The insert or update value of the FOREIGN KEY “INST1.MESSAGE.FK_1FUTL48XT47HPPGH0YXQM1MIJ” is not equal to any value of the parent key of the parent table.. SQLCODE=-530, SQLSTATE=23503, DRIVER=4.13.127 From IBM… Read More »

Oracle: Finding and adding indices

By | February 8, 2017

Sometimes things go slow in the database even if the original setup was done with a lot of care. The data traffic the usage of the application can sometimes impose the need of extra indices in addition to the original indices added by the enterprise application client that uses the Oracle database. The following procedure… Read More »

Microsoft SQL Server: Database Replication (Mirroring)

By | October 25, 2017

Microsoft SQL Server Standard Edition has a great feature present in this basic license: Database Replication in Synchronous mode. To activate the database replication of a database from Primary Site (PR) to Disaster Recovery Site (DR) where the database to be replicated is called myDB the following simple steps must be performed: On PR site… Read More »

Microsoft SQL Server: Snapshot isolation

By | February 9, 2017

Snapshot isolation is a guarantee that all reads made in a transaction will see a consistent snapshot of the database. The transaction itself will successfully commit only if no updates it has made, conflicts with any concurrent updates made since that snapshot. By using it, deadlock situations when a read operation (intense resource consuming operation)… Read More »

DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null

By | February 21, 2019

This error is the DB2 cryptic way of informing you that a value which an insert query tries to insert in a table is too large. Usually when using java + hibernate we can define a member of an EJB as: @Column(length = 10) protected String receiver; If somehow when the object is created we… Read More »

DB2 + Websphere : Feature is not implemented: PreparedStatement.setBinaryStream

By | February 8, 2017

From a very strange reason after updating the hibernate4 from version 4.1.4 to 4.2.5 there was suddenly a weird behaviour of the EJB3.1 enterprise application I am working on. A piece of code that commits to the database an object (ProcessingStatus) containing a BLOB was throwing the following: [1/31/16 23:37:15:922 EET] 000000eb AbstractBatch Z org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl… Read More »

Hibernate+DB2 : Adding new primitive data type member to an entity issue

By | February 8, 2017

This is an annoying issues of hibernate with DB2. Trying to add a new primitive type to an already existing entity will result in an error when updating the associated database table. As a result no update of the schema is done. Why is that ? When adding to an entity a new primitive type… Read More »

Oracle: Get the real size of a table with blobs

By | February 8, 2017

As we now in case of a table with BLOBs in the actual table row only a reference to the BLOB is stored. In order to get the real table size of my table ‘MY_BLOB_TABLE’ including the refereed BLOBs the following query holds in Oracle: SELECT sum( bytes)/1024/1024 size_in_MB FROM user_segments WHERE (segment_name = ‘MY_BLOB_TABLE’… Read More »

Oracle: Resolve blocking processes

By | February 8, 2017

Sometimes an oracle query goes nuts and blocks the DB. To find the blocked processes started by user MYUSER execute: SELECT s.inst_id, s.sid, s.serial#, p.spid, s.username, s.program FROM gv$session s JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id where s.username like ‘MYUSER’; To kill the blocking process: ALTER SYSTEM KILL SESSION ‘sid,serial#’