JBoss AS and JDBC DataSource tutorial

In this post I’d like to share my own expericence of creating of out-of-the-box database solution using JBoss AS, JPA and EJB 3.1

Read the rest of this entry »

PostgreSQL XPath tutorial

In this post I’d like to show some practical examples of XML processing in PostgreSQL using XPath

Read the rest of this entry »

jHolidays project

Some time ago I’ve decided to create a small utility which will be able to create ICal calendar using input file (listing of events, holidays etc). Read the rest of this entry »

Microsoft SQL Server – Complex Cleanup

Today my team manager asked me to create small interesting sql script. This script recieves time interval on input, splits given time interval into smaller parts (let’s say 24 hours per interval), counts total number of records for each interval, outputs this information and deletes records. Script mustn’t delete top”fresh” records though. E.g. manager would like to specify offset parameter, so records from interval [today-offset;today] mustn’t be deleted. Read the rest of this entry »

Microsoft SQL Server – gathering tables information

Let’s examine how we can output some statistical information about database tables.

Read the rest of this entry »

Oracle stats (Part 3)

Finally let’s find out how to gather per table statistics.

Read the rest of this entry »

Microsoft SQL Server – statistics

I’ve recieved interesting task from my boss. I need to prepare a few stats for MS SQL Server so let’s do it.

Read the rest of this entry »

Oracle stats (Part 2)

This time we will monitor tablespace stats. I’d like to create one stats table per tablespace and use the same technique as in Part 1

Read the rest of this entry »

Oracle stats (Part 1)

Our customer runs Oracle database and my chief has given me a task to do for today.

I need to prepare prognosis of how much oracle database will grow in next 3 years. After short googling I’ve found interesting sripts [1]:

 select sum(bytes)/1024/1024 "Meg" from dba_data_files;
 select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;
 select sum(bytes)/1024/1024 "Meg" from sys.v_$log;
 select sum(BLOCK_SIZE*FILE_SIZE_BLKS/1024/1024) "MEG" from v$controlfile;

The main idea is to create oracle DBMS job which will fire each hour for let’s say 7 days (yeah, we’ve got only 7 days :() and outputs statistics about database size into some database table.

Read the rest of this entry »

SyslogMessageMapper

Now when SyslogSessionMapper has been implemented, it time to finish SyslogMessageMapper. But before let’s remind us syslog use-case .

One thing that we will have to implement is retrieving syslog messages using different conditions. Here is preliminary list of conditions:

  1. Get messages by category name(s)
  2. Get messages by type name(s)
  3. Get messages by sender name(s)
  4. Get messages by session(s)
  5. Get messages by time interval(s)

The list can be continued…

This is the best place to use Query Object pattern. For futher reading please refer to:

http://codebetter.com/blogs/gregyoung/archive/2009/01/20/ddd-specification-or-query-object.aspx

http://www.theserverside.com/patterns/thread.tss?thread_id=29319

http://www.lostechies.com/blogs/chad_myers/archive/2008/08/01/query-objects-with-the-repository-pattern.aspx

http://martinfowler.com/eaaCatalog/queryObject.html

I’d like to take some time about base classes implementation, since we will use query object pattern in groupchat logger plugin. This plugin will store log of xmpp groupchat (conference) and we need to provide flexible OO mechanism for retrieving chat messages from log. So it would be nice to implement base classes for SyslogMessageMapper and reuse them later :)