I’m working on a huge legacy Java application, with a lot of handwritten stuff, which nowadays you’d let a framework handle. The problem I’m facing right now is that we are running out of file handles on our Solaris Server. I’d like to know what’s the best way to track open file …
Tag: java
How to map a PostgreSQL array with Hibernate
Has anyone successfully mapped a numeric array in PostgreSQL to a numeric array in Java via Hibernate? SQL: Mapping: Class: I get an exception when querying the table. Answer Hibernate does not support database arrays (e.g. ones mapped to java.sql.Array) out of the box. array and primitive-array types provide…
How should equals and hashcode be implemented when using JPA and Hibernate
How should model class’s equals and hashcode be implemented in Hibernate? What are the common pitfalls? Is the default implementation good enough for most cases? Is there any sense to use business keys? It seems to me that it’s pretty hard to get it right to work in every situation, when lazy fetc…
Netty vs Apache MINA
They both provide roughly the same functionality. Which one should I choose to develop my high-performance TCP server? What are the pros & cons? Reference links: Apache MINA (source) Netty (source) Answer While MINA and Netty have similar ambitions, they are quite different in practice and you should cons…
Authenticated HTTP proxy with Java
How can I configure the username and password to authenticate a http proxy server using Java? I just found the following configuration parameters: But, my proxy server requires authentication. How can I configure my app to use the proxy server? Answer (EDIT: As pointed out by the OP, the using a java.net.Auth…
“Cannot get the revision information from the scm repository”
I get maven error : Any idea how to solve this? Answer A quick search on Google seems to indicate that this error is related to the buildnumber-maven-plugin. However, I couldn’t reproduce the error on the command line on my machine (Maven 2.2.1, Java 1.6.0_16, svn 1.6.5 on GNU/Linux): From what I can se…
How to obtain all subsequence combinations of a String (in Java, or C++ etc)
Let’s say I’ve a string “12345” I should obtain all subsequence combinations of this string such as: –> 1 2 3 4 5 –> 12 13 14 15 23 24 25 34 35 45 –> 123 124 125 234 235 345 –> 1234 1235 1245 1345 2345 –> 12345 Please note that I grouped the…
Detecting cyclic dependencies with Maven
In my application I’m using an external library (Batik 1.7) that is made up of several modules. The modules have multiple cyclic dependencies between themselves. This doesn’t influence the build, but some tools (e.g. the M2Eclipse Dependency Graph, or the Dependencies report) will not work anymore…
How do I convert a byte array to a long in Java?
I am reading 8 bytes of data in from a hardware device. I need to convert them into a numeric value. I think I want to convert them to a long as that should fit 8 bytes. I am not very familiar with Java and low level data type operations. I seem to have two problems (apart from the fact
How to set classpath when I use javax.tools.JavaCompiler compile the source?
I use the class javax.tools.JavaCompiler (jdk6) to compile a source file, but the source file depends on some jar file. How to set the classpath of the javax.tools.JavaCompiler? Answer The javax.tools.JavaCompiler#getTask() method takes an options parameter that allows to set compiler options. The following m…