September 2005


I always forget how to do this.

UPDATE foo SET bar_date = TO_DATE( '2005-09-29', 'YYYY-MM-DD') WHERE foo_id=51

SELECT TO_CHAR(bar_date, 'yyyy-mm-dd hh24:mi:ss') FROM foo;

SELECT * FROM foo WHERE bar_date > TO_DATE('08/16/2006', 'MM/DD/YYYY')

When you need a date in a pinch for inserting test data use sysdate.

INSERT INTO foo (bar_date) VALUE (sysdate)

A good article about this is Oracle, SQL, Dates and Timestamps.

There is an excellent tutorial at The Java Tutorial called
Using the Timer and TimerTask Classes.

It explains how to use a timer to schedule tasks or to perform tasks repeatedly. With the Timer and TimerTask classes you don’t have to create your own threads, it’s all done for you. Thank you Joshua Bloch for writing these classes.

On a side note, Joshua Bloch is one of the premier Java engineers. Recently he left Sun for Google. Gosh, that must have hurt Sun.

Here is an example of how to create a sequence which you can use for creating sequential numbers, typically for ID’s.

CREATE SEQUENCE person_seq
    INCREMENT BY 1
    START WITH 1
    NOMAXVALUE
    NOCYCLE
    CACHE 10;

This is how you would then use the sequence.

INSERT INTO persons (id, name) VALUES (person_seq.NEXTVAL, 'Dylan')
INSERT INTO persons (id, name) VALUES (person_seq.NEXTVAL, 'Isaac')

If you want to select the next ID you would do it like this.

SELECT person_seq.NEXTVAL FROM Dual

To learn more, Managing Sequences and the Oracle DUAL table.

In one of our ATG servlet’s we were making a normal HTTP call to a page located on our ATG Dynamo server.

url = new URL(urlString);
connection = (HttpURLConnection)url.openConnection();
reader = new InputStreamReader(connection.getInputStream());

However when trying to get the input stream we got a FileNotFoundException yet we were able to go to the same URL using a browser. Googling around we found this lovely thread about the same problem.

To summarize the thread, the problem was in our proxy settings which are set on Windows in localconfig/environment.bat and on UNIX in localconfig/environment.sh. An example of proxy settings on Windows is set PROXY_ARGS=-Dhttp.proxyHost=192.168.1.134 -Dhttp.proxyPort=8080.

The proxy server did not recognize our machines as valid clients so it rejected our requests. Once we changed the proxyHost argument to point to a valid server then this problem was fixed.

To override the classes that would run on the ATG server, one simply copies your new classes into the locallib directory under the correct directory which corresponds to the package. To learn more, Modifying the Environment Settings.

However on an ATG Dynamo 4.5.1 server running on FreeBSD I found the locallib classes were not loading no matter how many times I restarted the ATG Dynamo server. I realized finally by accident that the reason these classes weren’t being loaded was because another ATG Dynamo server was running and because of this the Java process was not releasing its understanding of the CLASSPATH. Only after killing the second ATG Dynamo server process was I finally able to get the ATG Dynamo server to load the new classes.

I was receiving an error like this when trying to commit a file into subversion.

svn: File '/foo/bar.gif' has inconsistent newlines

After searching, I found this nice page explaining how to fix the problem.

Newline problems with Subversion

Essentially you need to do this before you do the commit.

svn propdel svn:eol-style bar.gif