JDBC: Autogenerated keys revisited.

Some months ago i wrote about retrieving auto generated values with JDBC from an Oracle Database: JDBC: Get autogenerated keys on a Oracle DB.

The solution i presented in the previous article doesn’t run in a Oracle Java Stored Procedure.

To accomplish this, use a callable statement like this:

final String sql = "BEGIN INSERT INTO foobar(id, b) VALUES (id.nextval, ?) RETURNING id INTO ?; END;";
CallableStatement cs = connection.prepareCall(sql);
stmt.setString(1, "bar");
stmt.registerOutParameter(2, Types.INTEGER);
stmt.executeUpdate();		
rv = rs.getInt(2);

This way you get the id generated by the sequence id without first selecting and then using it.

| Comments (0) »

02-Apr-08


WordPress 2.5 and http error codes

Am i the only one who’s annoyed that WordPress 2.5 sends a http 500 code if a commentor doesn’t fill in all required fields? Any Internet Explorer 6 or 7 user won’t see any error message but a “this page cannot be displayed!” page. Stupid decision.

Otherwise, the update went smooth as far as i can tell.

Edit: Oh dear… To me it seems that IE6 shows a browser default page everytime and IE7 sometimes displays the WP error page and sometimes not. If anyone can confirm this?

Edit 2: It’s silly. The Internet Explorer masks all 500 pages if their content is below a threshold of 512bytes with “User friendly messages”. User friendly your mom. The user can turn this off as described here but i don’t think that all IE users will do this just for the WP bloggers.

Summarizing it: It’s a plain stupid idea to use the http error 500 code for errors generated by user input as some users just cannot read them as the messages are not displayed to them.

| Comments (6) »

30-Mar-08


UI Design

Apple, Google and you:

dummy

Hilarious, but true. Although being somewhat different and currently under heavy critic (i.e. here) as far as Apple is concert, both Apples and Googles interface designs are appealing, at least to me and the comic summarize this very well: Do one thing and do this well.

The strip was posted here, i found it on this blog

| Comments (0) »

27-Mar-08


Feeling dizzy…

After staring at this

dummy

for about a day in various rotations and flips just to get Oracle GeoRaster work together with a homebrew GIS like application made me feel somewhat dizzy. To be cartesian or not cartesian, that is the question 😉

Otherwise, Oracle GeoRaster works quite well, at least for that bunch of german TK25 maps in GK3 coordinates that used to float around in the filesystem and are now being stored in the database.

| Comments (0) »

26-Mar-08


Handle EXIF data with ruby (and style…)

I use rmagick when it comes to deal with images. I’m not that disappointed like Zed Shaw with rmagick (but Zed is totally right when he points out on page 4: “[…] and is difficult to install (unless your computer is nearly exactly the same as the author’s).”), but when it comes to deal with EXIF, rmagick sucks big time.

After some searching i found another EXIF reader called “EXIF Reader” (EXIFR), which can be downloaded and installed from here or via gems.

I came mainly to this point becaus rmagick completly failed reading GPS data from my images (and it is hard to use with all other values).

EXIFR on the contrast cannot do image manipulation, so i needed both. Maybe i’m still just to new to ruby, but exifr gave me a hard time not reading the same image twice from file, once for rmagick and once for exifr.

I came up with the following solution:

require 'rubygems'
require 'RMagick'
require 'exifr'
image = Magick::ImageList.new("whatever_image.jpg")
exif_info = case image.format 
when 'JPEG'
  EXIFR::JPEG.new(StringIO.new(image.to_blob))
when 'TIFF'
  EXIFR::TIFF.new(StringIO.new(image.to_blob))
else
  nil
end

This uses rmagick to instantiate a magick image and then a StringIO object to build up the exif information if the image is a jpeg or a tiff image.

| Comments (5) »

09-Mar-08