Java

Optimising PostgreSQL application Part II

Review Part I here.  The best I could muster was 21 minutes in a co-located setup.  To make the comparison fair, I am going to express it as a percentage of the pre-optimisation application / PostgreSQL DB on production versus my development machine.

Wonderful Java and escape sequences...

Imagine you have this piece of text:

I am stupid\

And what to change it to

I am stupid\\

so that it may be saved correctly to the database (assume you are not using prepared statements). A first attempt might be:

new String(Base64Coder.decode(pFieldData)).replaceAll("\\","\\\\");

because you are clever and know about escaping a single \ with another one \\ to produce a \.  Sadly that will not work.  The \\ expands to one \, and that is one part of the \\ you need for the regular expression.  This is what you need to do - insane:

Blog Categories:

My MBeans do not show up in jmx-console on Jboss 6

I have been trying to port an application of mine to JBoss 6, and managed to get there from JBoss 5.1.0.CR1 without too much hassle.  However my MBeans did not show up...

I could find no information as to why this is broken on the wonderful internet.  I tried posting on JBoss' forums but as usual, I was ignored on there.  Never get any responses.  Guess you have to pay for that.  I am digressing.

Eventually I figured it out.  Here are the details:

Blog Categories:

JBoss Seam application not working under IE9

I have developed an application in JBoss Seam 2.2.1.Final using RichFaces 3.3.3.Final.  Some parts of the code make heavy use of a4j calls, i.e. Ajax calls.  This works very well under most browsers.  Unfortunately when IE9 was released two weeks ago, it refused to work with my application.  I would click on certain links and nothing would happen.  Or I'd get blank pages back.

Eventually I traced the issue to a known bug in the Sarissa.js file that is used by RichFaces for XML and DOM parsing.  This file in RichFaces 3.3.3.Final is not compatible with IE9.

Blog Categories:

JBoss Seam throwing java.lang.OutOfMemoryError: PermGen space

I have been pulling my hair out at the JBoss error:

java.lang.OutOfMemoryError: PermGen space

when trying to start JBoss.  It starts fine with one of my ear files, but when I added the second ear file it loads, but on access of any page in JBoss it crashed.  After two hours of this, I finally figured it out.

See, the second application is a JBoss Seam application.  Why is this important?  JBoss Seam has a LOT of classes that needs to be loaded, much more than my other application.  This is relevant because I had this in my run.conf in JBoss:

Blog Categories:

JBoss Seam and i18n woes

Recently I had to make my JBoss Seam web application support both English and Georgian.  Naturally their character set is not to be found in ASCII, so I had to rely on JBoss Seam and Java's support for UTF-8.

Blog Categories:

JBoss Seam loses conversation state

I developed a very well oiled JBoss Seam application, which has been working great.  However my client today told me they could not save anything.  Curious, I investigated.

It seems like none of my conversation states are being remembered.  Needless to say, in a Seam application this wreaks havoc.

By applying simple deductive reasoning, I tracked the problem down to this recent addition:

Blog Categories:

When to use checked exceptions and when not to

I guess there would be three groups of Java developers out there - those who know about exceptions but have never heard of checked and unchecked exceptions, those who know what it is but do not understand them and those who truly know and understand them. My educated guess is that most people fall in the former two categories. This article will try and explain the differences between the two kinds of exceptions, as well as when to use which.

Blog Categories:

Validating user input

When should you perform input validation, and how thorough should you be? This is a question many developers are struggling with.

Blog Categories:

When to return null and when to throw an Exception?

I am pretty sure once you transcend the youth phase of software development, and you start thinking about what you are actually doing whilst writing code, you'll start running into tough decisions such as when to throw an exception, and when to return null.

Blog Categories:

Pages

Subscribe to Java

Back to top