Tuesday 15. June 2010 kl. 08:51

Writing the results from an SQL query directly to a file in DBVisualizer

Posted by Hugi Thordarson

If you want to write directly to a file, just do:

@export on;
@export set filename="/tmp/bigassquerydata.csv";

select * from huge_table

The default format of the outputted data is CSV, but you can specify a different format by adding a 'format' parameter to the @export directive, like so:

@export on;
@export set filename="/tmp/bigassquerydata.sql"  format="sql";

select * from huge_table

More information in DBVisualizer's documentation.

Monday 16. November 2009 kl. 09:04

Oracle Sequences and WebObjects

Posted by Atli Páll Hafsteinsson

Like those of us using WebObjects in combination with an Oracle database know, WebObjects uses sequences in Oracle to create serial keys. For table CUSTOMERS WebObjects would required a Sequence named CUSTOMERS_SEQ for the generation of key, that is to be able to generate serial keys WebObjects requires a Sequence with the same name as the table post fixed with _SEQ. This is fine as long as there is not already existing a sequence that serves this purpose with a name that does not follow this naming rule. This is often the case when developing against a database used by other applications or an old database.

Luckily that is no problem, Oracle has something called Synonyms that can act as an alias or link between objects in the database. Simply create a Synonym with a name that complies to the WobObjecst sequence naming rule and make it point to the old sequence.

For example if you had a sequence for the CUSTOMERS table called CUSTOMERS_ID_GENERATOR:

CREATE SYNONYM "SALES".CUSTOMERS_SEQ FOR "SALES".CUSTOMERS_ID_GENERATOR

This creates a WebObjects usable synonym for the Sequence CUSTOMERS_ID_GENERATOR in the SALES Schema and yet again WebObjects can live together in harmony.

Tuesday 27. October 2009 kl. 15:31

Forritaraspjall hjá Umferðarstofu

Ágætu forritarar á Íslandi og um veröld alla.

Við hjá hugbúnaðardeild Umferðarstofu höfum ákveðið að bjóða öllum áhugasömum mánaðarlega til forritaraspjalls í húsnæði Umferðarstofu við Borgartún 30.

Við viljum halda umgjörð viðburðanna fremur óformlegri og frjálslegri og er öllum boðið að mæta sem áhuga hafa á hugbúnaðarsmíði. Áhugasamir mega einnig gjarnan halda kynningar á málefnum tengdum hugbúnaðarsmíði, vilji menn deila með öðrum einhverju sérstaklega spennandi sem þeir eru að skoða eða vinna að hverju sinni.

Stefnan er að gera þetta fyrsta þriðjudag hvers mánaðar og fyrsti hittingurinn verður haldinn þriðjudaginn 3. nóvember næstkomandi kl. 17:00.

Á þessum fyrsta hittingi mun Hugi Þórðarson hjá Umferðarstofu sýna stuttlega hluta af opnum kóða Umferðarstofu. Hafi fleiri áhuga á að halda kynningar þá endilega sendið póst á Huga með tilkynningu þar um. Góð aðstaða er á staðnum, skjávarpi og pláss fyrir um 30 manns.

Hafir þú áhuga á að mæta ertu vinsamlegast beðinn að senda tölvupóst á Huga og tilkynna mætinguna sem fyrst.

Sjáumst á forritaraspjalli!

Friday 16. October 2009 kl. 10:47

Vehicle registrations in Iceland at an all time low

Roughly 4200 vehicles have been registered in Iceland since January 1st 2009. That's a drop of 75% when compared with the same period in 2008. The graph pictured below shows the number of registered vehicles in Iceland since January 1, compared with the same period in the past 4 years.

Monday 10. August 2009 kl. 15:04

First open source release

Posted by Hugi Thordarson

For some time, we at Umferdarstofa have been planning to open source our code. Today, we officially started our open sourcing initiative by creating a new library for our base java classes and hosting it on Google Code. As can be seen from glancing at the repository, we are starting out small, but as time progresses, most of our code will find a home in this repository.

Please note that the code is released as an Eclipse WebObjects-project, and is thus as it stands simplest to use in a WebObjects-environment. But we are planning to change this to a pure java project in the coming weeks to make it easy to integrate in other java applications and projects.

Two classes of note for Icelandic developers in this small first release are:

  • USPersidnoUtilities
    Utility class for working with Icelandic National PIDs (Kennitala)
  • USHolidays
    Code for calculating all Icelandic holidays in a given year, acording to the current rules.

USJava on Google Code.

Monday 10. August 2009 kl. 13:35

Public build servers for Project Wonder/WOLips

Posted by Hugi Thordarson

Quinton Dolan, also known as "Q" on the WebObjects mailing lists, has set up a public Hudson build/continuous integration server for Project Wonder and WOLips. The server can be found at http://webobjects.vstrata.com.au/hudson/.

Wednesday 5. August 2009 kl. 14:52

Backing up Eclipse Launch Configurations

Posted by Logi Helgu

I needed to clean my workspace in Eclipse so I deleted all the projects and checked them out again from the repository just to realized  that I had lost all my Launch Configurations [LC].   That's pretty annoying since I have a specific port for each application and different setups for connecting against live, mock or test databases.  Export/Import to the rescue.  I was pretty sure that I had recently exported my LC a few weeks ago when I had to create them all over again.  After a little digging I found the exports and after a little more time I figured that I could import the whole bunch of them by selecting the folder the resided in.  I was one happy little camper not having spend time on creating the LC again...so I "spent" some time writing this instead =)

To backup (export) your LC in Eclipse:
1. Select File from the Eclipse Menu
2. Select Export
3. Select Launch Configurations (under Run/Debug) and click Next
4. Select the LC to export and the location to store them and click Finish

To restore (import) your LC in Eclipse (pretty much the same process except you choose Import) :
1. Select File from the Eclipse Menu
2. Select Import
3. Select Launch Configurations (under Run/Debug) and click Next
4. Locate the directory with the LC and select the LC you want to import and click Finish

Wednesday 24. June 2009 kl. 11:17

Searching for a string in Oracle code

Posted by Hugi Thordarson

Sometimes you need to find a string buried in millions of line of Oracle PL/SQL-code. In this case, you have two choices: (a) Shoot yourself or (b) do this:
SELECT * FROM USER_SOURCE WHERE lower(text) like '%somestringtosearchfor%' order by name ASC, line ASC

Wednesday 27. May 2009 kl. 15:02

Zzzzzzzzz....

Posted by Hugi Thordarson

Friday 22. May 2009 kl. 16:43

Scala's syntax heaven

Posted by Hugi

I've been playing around with Scala in the last few days... I must say that the Scala syntax is really nice and concise - it really works hard to eliminate the boilerplate code we all spend far too much time writing.

If you don't believe me: see for yourself (it's an extreme example, I know - but it goes to show how a little change can go a long way). The magic that's going on here is that variables declared in the constructor will automagically become class properties. A lovely little feature.

Scala:

class DBConnectionInfo( var url:String, var username:String, var password:String ) {}

Java:

public class DBConnectionInfo {

	private String _url;
	private String _username;
	private String _password;

	public DBConnectionInfo( String url, String username, String password ) {
		setUrl( url );
		setUsername( username );
		setPassword( password );
	}

	public void setUrl( String _url ) {
		this._url = _url;
	}

	public String url() {
		return _url;
	}

	public void setUsername( String _username ) {
		this._username = _username;
	}

	public String username() {
		return _username;
	}

	public void setPassword( String _password ) {
		this._password = _password;
	}

	public String password() {
		return _password;
	}
}

Aðrir vefir Umferðarstofu