Some Resources for Sony Alpha Development

Every time I get a gadget I think of building something for it. Since I’ve gotten a Sony A6000 things are not different, particularly because I have some issues with the default Sony Android app requiring GPS location (and insisting not to work without it). Therefore, I would like to build an app which makes […]

HTML to PDF with iText 2.1.7

Sometimes you need to use an older version of a product die to e.g. licensing changes. It’s my case with iText. While the new version looks fantastic, their changes (and removal of e.g. RTF output) are deal breakers for the feature set we need to maintain. Therefore, 2.1.7 is the most recent version we can […]

Call an Oracle Function from Spring with CallableStatement

Following the previous post, I wondered if there’s a more elegant way to call a function. It turns out there is and it’s based on CallableStatement:

The CallableStatementCreator sets up the statement and the CallableStatementCallback executes the statement and returns the value up to the execute() call. Having a function:

We can build […]

Call an Oracle Function from Spring

The easiest way to call a function from Spring is using SELECT. For example, having a function HAS_PANEL_FLAG_OK with two parameters and returning an integer, the function call looks like:

This will return all flags for the panels matching the condition. Java Call The query string can be something like:

and the actual […]

List Columns in a ResultSet

In order to list all columns in a JDBC ResultSet (e.g. for debug purposes), you need to iterate through its metadata:

Note: Column numbers start from 1, not 0 (hence the md.getColumnName(i + 1) above). I usually wrap this in a if(logger.isTraceEnabled()) so it doesn’t get triggered all the time. HTH, A little experiment: […]

Pass Through a Corporate Proxy in Java

TL;DR: There’s no easy way to create a proxy :) I’ve tried for a while to build a way to request something through a proxy, for testing an emulated android app. The solution came from Octavian who kindly provided me a snippet to run once per app lifetime. It tackles the problem from two fronts: […]

Mock an Observable Interface

TL;DR: Use a doAnswer() with a new Answer<Observable<Type>>() if you have to mock observables. Today I wrote my first test where I had to mock an observable interface:

where the User model is:

Solution In my test class (named UserDatabaseTest), I first mocked the interface:

` Then, my setup() method is:

[…]

Load Glyphs with LibGDX

TL;DR: Remember to give the font loader the list of characters to render from the font! I’m trying to get a more resolution-independent mechanism to load simple shapes in place. After investigating SVG loading for several days I got nowhere. Then, I found out that libGDX actually supports vector fonts (TTF). Woo-hoo! Internally, it’ll convert […]

About Java Exceptions in SE 7

TL;DR: JDK 7 improves on exception handling (less code, base exception class…). Base exception class Reflective operations exceptions now have a base class ReflectiveOperationException. This allows you to to a global catch rather than one for each exception. Now you can write:

Note: Reflective operations are ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchFieldException, NoSuchMethodException. Multi-catch Previously, […]

Scroll to top