Hibernate course completed

I’ve completed yesterday the course Object-Relational Mapping with Hibernate: Hands on. Although I’ve already used Hibernate before, it was very valuable to refresh and expand my knowledge on the topic. I was quite doubtful whether to enrol or not, but I am now glad that I did!

. . . → Read More: Hibernate course completed

Spring JDBC Template

Spring JDBC template is helpful to reduce boilerplate code, to use it, I first define a bean that use a data source, called dataSource, defined as in the previous post. . . . → Read More: Spring JDBC Template

Defining a JNDI DB connection with Tomcat

1. Install Your JDBC Driver

Copy the driver’s JAR file(s) into the $CATALINA_HOME/lib directory, which makes the driver available both to the resource factory and to your application.

2. Bootstrap the project

If you don’t have a project to play with already, you can bootstrap a project with Spring Roo. I’ve used version 1.2.1. I . . . → Read More: Defining a JNDI DB connection with Tomcat

Dumping and Restoring Data with Google App Engine

Google App Engine has a way to dump and restore data, using the bulkloader.py command from Python SDK.

To be able to use it with a Java application, first we’ve to map the RemoteApiServlet in web.xml

<servlet> <servlet-name>RemoteApi</servlet-name> <servlet-class>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>RemoteApi</servlet-name> <url-pattern>/remote_api</url-pattern> </servlet-mapping>

Here is the command to dump all the instances of . . . → Read More: Dumping and Restoring Data with Google App Engine

Hibernate and MySQL

Since I’ve already wrote about PostgreSQL and H2 Hibernate configuration, I thought it’s a good idea to add MySQL too for my reference.

First I’ve added the dependency to Maven’s pom.xml (see the Maven repository for the latest version).

<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.18</version> </dependency>

The second step is Hibernate configuration, here is an example:

. . . → Read More: Hibernate and MySQL

Hibernate and H2

H2 is a small embeddable Java Database that supports a in memory mode (it also has a server mode). It’s a great choice for testing, since it doesn’t require any DB set up.

To try it out, the first step is adding the dependency to Maven’s pom.xml (see the Maven Repository for the latest version).

. . . → Read More: Hibernate and H2

Hibernate and PostgreSQL

I’m finally fluent in Spring and Spring-MVC and I am studying Hibernate. If I think about DBMS that I’ve been using, I can recall SQL Server, Oracle and a lot of MySQL. As for PostgreSQL, I kept on hearing good news about how robust and standard based it is, but I’ve never had a chance . . . → Read More: Hibernate and PostgreSQL

A simple Roundcube optimization

Roundcube is a nice Ajax based webmail, but I was experiencing slow performance. I checked MySQL slow query log and I found queries taking several seconds. Expecially session and cache-update queries were taking as much as 9 seconds. This is really a long time for an interactive and fluid user experience. I’ve checked Roundcube version . . . → Read More: A simple Roundcube optimization

MySQL replication

It’s interesting that MySQL replication works also with an unreliable connection. It won’t be up to date all the time, obviously, but it should still work. With this in mind I wanted to keep a copy of a database on my laptop on another computer of the office. I want to keep my laptop on . . . → Read More: MySQL replication

MySQL: ORDER BY RAND() is slow!

I knew already, but I was caught again. I was wondering why my Java WebService was slow, I thought to profile the code, but when I checked the process list on the server I saw that MySQL was taking a lot of CPU time.

I looked into queries and I saw that in one of . . . → Read More: MySQL: ORDER BY RAND() is slow!