All zero dates, mysql, and jdbc

Cannot convert value '0000-00-00 00:00:00' from column N to TIMESTAMP

Familiar? This problem arises because ‘null’ dates in MySql are generally represented as ’0000-00-00 00:00:00′, which, while valid in MySql, are completely forbidden in jdbc.

There is a wonderful workaround however, simply add the zeroDateTimeBehavior parameter to the end of your jdbc url as follows:

jdbc:mysql://hostname/dbname?zeroDateTimeBehavior=convertToNull

And that’s it, zero dates will be converted to nulls and jdbc will be happy.

Popularity: 4% [?]

,

No Comments

iPhone 3.0 Update, but no delivery reports

How could apple develop things like MMS, vCard support, and even peer-to-peer connections for the iPhone, and yet omit gaping holes like SMS delivery report support?  I’m starting to think that SMS delivery reports don’t work in Cupertino.

Edit (July 2009): If you’re interested in getting this feature added to the iPhone OS, please vote for it here: Please Add Delivery Reports to the iPhone.

Update (October 2009): No more silliness with prefixes needed – if you’ve a jailbroken phone, you can now get genuine delivery reports. More info here.

Popularity: 8% [?]

, , ,

1 Comment

The Millimetre Crisis in Hoodwinked Kingdom

The Great Big Millimetre Crisis in Hoodwinked Kingdom. by Christopher Brooks

It came about that a whole kingdom was cast
over by a spell from a tiny sect in it’s territory
that from this day forth all “millimetres” belong and are
controlled in supply by their new “mm” bank.

This sect grew in power and found many clever
ways to manipulate and pervert the “mm” from
it’s genuine honest scientific function as a stable
medium of exchange.

The sect grew it’s influence by supporting
the Hocus Pokus University to research
the scarcity of “mm” theory and the
Spellmaker Press always published
the “Coping with limited “mm” stress”
reports. Read the rest of this entry »

Popularity: 4% [?]

,

3 Comments

htmlspecialchars for mysql

Yes, it’s bad, evil, nasty, and just plain wrong.

But that doesn’t mean that there aren’t occasions when you do need to spew out html directly from mysql (or at least I’ve found one).

DELIMITER $$

DROP FUNCTION IF EXISTS `htmlspecialchars`$$
CREATE FUNCTION `htmlspecialchars` (_str text) RETURNS text
BEGIN
	set _str = replace(_str, '"', '"');
	set _str = replace(_str, '&', '&');
	set _str = replace(_str, '<', '&lt;');
	set _str = replace(_str, '>', '&gt;');
	return _str;
END$$

DELIMITER ;

Usual disclaimers apply.

Popularity: 4% [?]

,

No Comments

‘Revert’ does not mean ‘Reply’

I’ve seen three occurrences of this stupidity recently (all, as it happens, in communications to/from Irish solicitors), and it is really starting to vex me.  Particularly because the people involved should all know better.

Generally, the usage tends to be:

Please revert to me

which, while grammatically correct, only has meaning if the person you are writing to was, at some time in the past, you. Read the rest of this entry »

Popularity: 15% [?]

1 Comment

Java 1.6 on OS X

Today I was presented with the following error

java.lang.UnsupportedClassVersionError: Bad version number in .class file

My first instinct was of course that I must be using an older vm on the machine in question (an OS X 10.5.6 server), but no, java 1.6 was installed on this machine:

~$ ls -alF /System/Library/Frameworks/JavaVM.framework/Versions/
total 56
drwxr-xr-x  14 root  wheel  476 25 Sep 10:43 ./
drwxr-xr-x  12 root  wheel  408  1 Nov 18:28 ../
lrwxr-xr-x   1 root  wheel    5 25 Sep 10:43 1.3@ -> 1.3.1
drwxr-xr-x   3 root  wheel  102  2 Nov  2007 1.3.1/
lrwxr-xr-x   1 root  wheel    5 25 Sep 10:43 1.4@ -> 1.4.2
lrwxr-xr-x   1 root  wheel    3 16 Jun  2008 1.4.1@ -> 1.4
drwxr-xr-x   8 root  wheel  272 25 May  2007 1.4.2/
lrwxr-xr-x   1 root  wheel    5 25 Sep 10:43 1.5@ -> 1.5.0
drwxr-xr-x   8 root  wheel  272 25 May  2007 1.5.0/
lrwxr-xr-x   1 root  wheel    5 25 Sep 10:43 1.6@ -> 1.6.0
drwxr-xr-x   8 root  wheel  272 16 Jun  2008 1.6.0/
drwxr-xr-x   8 root  wheel  272 25 Sep 10:43 A/
lrwxr-xr-x   1 root  wheel    1 25 Sep 10:43 Current@ -> A
lrwxr-xr-x   1 root  wheel    3 25 Sep 10:43 CurrentJDK@ -> 1.5

A little further investigation revealed that, even though 1.6 is installed, 1.5 is still firmly the default:

~$ java -version
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
Java HotSpot(TM) Server VM (build 1.5.0_16-133, mixed mode)

Thankfully, this can be changed by aliasing java to the 1.6 version:

~$ alias java=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java
~$ java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)

Do this in your .profile to make it stick.

In fact the solution was simpler than the above for me, I just had to put

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home

in my tomcat startup script (since I only needed the 1.6 jvm in tomcat).

Popularity: 4% [?]

,

No Comments

Calling SAP from PHP (on OS X)

You’d think it’d be easy eh?

  • My first google turned up SAPRFC, an extension module for php which allows direct ABAP calls from php.  ‘Perfect’, I thought, until I discovered that it is now essentially unmaintained, and it seems that no one ever tried it on OS X in the first place.
  • Very very happy was I then when I discovered its (very new) successor: sapnwrfc.  But no one has bothered to compile this yet on OS X either (and, like its predecessor, it requires the SAP RFC SDK, which I don’t have).  And besides, it really is very new, just a month or so old – not suitable for production then.
  • So I resigned myself to using another language to bridge the gap.  My first thought (my first hope really), was perl.  This turned up SAP::Rfc, written by the same guy who’s creating sapnwrfc.  But this also requires the SAP RFC SDK, and I couldn’t find anyone who’d ever compiled this on OS X.
  • So why not Java?  The SAP client my employer would have me use is pure Java, so surely I could use the same technologies?
    And this is where I stand at the moment: Use PHP/Java Bridge to call from php to Java, and SAP JCo to call from Java direct to SAP.

Yes, it’s cludgy, horrible, and sounds stupid.  And it probably is stupid.  But it’s how I plan to proceed for the present.  Tomcat will host the Java VM, and – if all the PHP/Java Bridge documentation is to be believed – there will be no need for Java ‘glue’ code, I should be able to use the JCo code directly in php.

If I live through the experience I’ll post more info about this soon.

Some pre-emptive defence: I know there are other technologies which would be preferable to my current solution – but I can make no changes whatsoever to SAP, this severely restricts my options.

Popularity: 5% [?]

, ,

No Comments

“Magic Time” on Friday 13th

MySql FROM_UNIXTIME

MySql FROM_UNIXTIME

Friday 13th Feb, 2009 is significant, not just because because it’s unlucky and the world will end etc., but moreso because, at 11:31:30pm UTC on Friday, Feb 13, 2009, Unix Time will reach 1,234,567,890.

It seems this time is becoming known as the ‘Cool Epoch’.

Popularity: 3% [?]

No Comments

Tigre Delta

Armed with her new camera, we decided to take a trip to El Tigre Delta, a little upriver from Buenos Aires yesterday.  It’s a beautiful place, a long way from our daily lifestyles.  Hope was expressed that we could spend our summer holidays there this year.

DSC00379.jpgDSC00469.jpgThe Petrol Station

The google map thingy below shows where it is.


View Larger Map

Popularity: 5% [?]

, ,

No Comments

The Defragmentation Brigade

These people epitomise all that is bad about computer-care.

  • They read a book once, it had ‘Technical’ in the title.
  • They read a website once, it had ‘Tweaks’ in the title.
  • They fix their mom’s computer, installing realms of free anti-spyware software when doing so.
  • They enable the windows firewall on a trusted lan, and install another firewall for good measure.
  • They use the words ‘Anti-Virus’, ‘Anti-Spyware’ and ‘Firewall’ interchangeably.
  • They say things like ‘fix it in the bios’.
  • Their favourite piece of software is called ‘Super Extra Registry Clean Optimizer’ (order of adjectives varies).
  • They know all about ‘l-eye-nux’: It’s fast, efficient, wonderful.  Some day they know they’ll try it too.
  • And they honestly believe, despite all evidence to the contrary, that defragmenting a computer hard disk fixes issues.

So, if you ever have a computer problem, and someone gives you some advice containing the word ‘defragment’, consider running away, very fast.  God has a special level of hell reserved for these people, and you don’t want to be near them when he sends them there.

Popularity: 6% [?]

, , ,

No Comments