Languages
 
 
 
 
Follow Me



 
 

java

Unexpected database connection problem. Hibernate broken pipe.


  Tagged

While using Hibernate, several times I faced the same database communication problem: for some reason after long inactivity time connection was closed. Each time that happens it takes some my time to remember the solution. So this post is more like a note for myself, but also can be helpful for those who can find it in Internet.


Hibernate. Count queries without HQL


  Tagged

I like to use Criteria class for making database queries. Its easy to use and easy to understand, much better then HQL queries. For example:

	@SuppressWarnings("unchecked")
	public List<LogAdd> findAddLogs(Long minLogID) {
		Criteria criteria = session.createCriteria(LogAdd.class);
		criteria.add(Restrictions.gt("id", minLogID));
		criteria.addOrder(Order.asc("date"));
		return criteria.list();
	}

Previously I had to use HQL only for writing 'count' type queries. Because just trying to get collection size mean to load all elements into memory from database and only then count them. Of course such kind of code isn't acceptable.


Installing Apache Tomcat 5.5 on Debian 4 (Etch) Linux


  Tagged

If you need to install and start Apache Tomcat quickly, probably this article can help you.

1) Sun JDK 5 need to be installed. It can be installed from Debian repository with unstable software

Add to /etc/apt/sources.list following lines (if not present yet):

# for sun-java packages in unstable
deb http://ftp.debian.org/debian/ unstable non-free
deb-src http://ftp.debian.org/debian/ unstable non-free


Java Application Process Name in Mac OS X


  Tagged

I have found that several of my Java applications have same process name on Mac OS X. JavaApplicationStub utility is usually used for launching java applications on mac os and as the result there are several processes named 'JavaApplicationStub' in Activity Monitor shown.


I have created simple HelloWorld application to reproduce this problem. And I was really surprised when saw that it's process name was correct!






New project with maven (small help note)


  Tagged

Once in a while I need to make small java applications maybe for testing some library, maybe as helper applications. As for me the fastest way to do this, is use maven archetype mechanism. But new project creation command not very user friendly since it required several parameters that you need to remember (‘-DarchetypeGroupId’ or ‘-DgroupId’). As solution you can make small help script and put it into your projects folder.

As quick solution I make small shell script (new_project.sh) that can be used for fast start:


Resume


  Tagged

Mr. Dmitry N. Kobyleha

human readable contact information

Objectives:

  • JAVA Developer (4 years of experience)
  • HTML/JavaScript Developer (4 years of experience)
  • XML/XSLT Developer (3 year experience)

Little more about Java I/O Performance


  Tagged

Working on performance in one of java projects I found that the slowest part is copy method from file utility class. Method was implemented without buffering. Implementation was next: just using ‘while’ operator reading input stream and writing to output stream.

There are good article about i/o performance on sun website.

Listing 4-4 from article looks good, but provided method not perfect too. I have next reason: my application is a multithreaded application. And anytime I synchronize on a static field, I make a bottleneck, because all threads must block while waiting to enter the synchronized block of code.


 
© 2006-2010 kobyleha.com