Risks category archives

Be careful with JavaScript variable declarations

Make sure you declare all your JavaScript variables exactly once. Otherwise it’s easy to introduce bugs that are hard to diagnose, especially if you’re used to programming in a C-like language such as Java, C++ or C#.

WordPress vs. mod_security

WordPress blog posts with certain words in them can sometimes be blocked or fail mysteriously. Sometimes the offending word is silently removed from the post; other times the post fails with an HTTP error. Here’s a description of one possible cause, together with a useful workaround in case this problem happens to you. The problem […]

Java versus Daylight savings time

Depending on the version of the Java runtime and the location of the host, the Java Date and Calendar routines may take daylight savings time into account. For example:

java.sql.Date is not a real date

java.sql.Date stores only date information, not times. Simply converting a java.util.Date into a java.sql.Date will silently set the time to midnight. So, to store date/times to be manipulated as java.util.Date objects, don’t do this:

// BUG: loses time of day
preparedStatement.setDate(1, new java.sql.Date(date.getTime()));

do this instead:

preparedStatement.setTimestamp(1, new java.sql.Timestamp(date.getTime()));

java.sql.Timestamp extends java.util.Date, but it should not be used as a […]

Oracle silently truncates dates

According to the documentation, the Oracle DATE type does not store fractions of a second. So if you store a date/time value including fractions of a second and read it back, you’ll get back a slightly different date/time. This will cause exact date matching code in your appplication to fail.

Oracle empty string = null

In Oracle 8, there is no such thing as a zero-length string. Any zero-length string, either from a function call or the literal ”, is treated as null.

Close
E-mail It