java
Simple GNU command line parser in Java via Apache commons CLI
I like Apache Commons CLI and I really like the GNU style command line argument / option parsing. The one thing with the commons CLI is that it covers a lot of use cases, but I find it a bit cumbersome to set up again and again for some of my CLI programs, so I [...]
Java: Date, ISO string, and timezone
This is a convenience class around SimpleDateFormat to parse/format date from/to ISO string: yyyy-MM-dd’T’HH:mm:ssZ. The printing bit allows for timezone to be specified, which just wraps around DateFormat’s .setTimezone() method. Note that Date object in java is not timezone-specific. The Timezone conversion is required only during formatting. Usage String date = "2009-09-10T10:00:00+0000"; Date d = [...]
Handling Oracle cursors in JDBC
Summary It is common practice for Oracle stored procedure to pass cursors to calling client. The client then needs to guarantee that the cursors are handled and closed properly, otherwise overtime the open cursor will accumulate into an ORA-1000 error (“ORA-1000 Maximum Number of Cursors Exceeded”) In Java world, cursor translates as ResultSet. In the [...]
Debugging a remote java application with Eclipse
You can remotely debug a java application by first starting it like below. java -Xdebug -Xrunjdwp:transport=dt_socket,address=8888,server=y …. Then, any decent IDE (such as Eclipse) with facility to remote debug a java application will be able to attach into the running process under the specified port (in this case, 8888). in Eclipse: Run > debug configurations [...]