MrUll's

November 06, 2006

sql for lagging over a calculated column

assume you have the following data:






idcrtl c1 c2 c3 result
1 1 12 -1 -1 12
2 2 -1 7 4 12+7=19
3 2 -1 9 8 19+9=28
4 3 -1 5 7 28+7=35
5 1 18 2 3 18


crtl defines how to calculate the result:
1 reset with c1
2 old val of result + c2
3 old val of result + c3

with the help of the model clause you can get the result, even with a readable statement.


SQL> select crtl,c1,c2,c3, result
from (select * from mytest order by id)
model
dimension by (id)
measures (crtl,c1,c2,c3,result)
rules (
result[ANY] = case crtl[cv()]
when 1 then c1[cv()]
when 2 then result[cv()-1]+c2[cv()]
when 3 then result[cv()-1]+c3[cv()]
else 0 end
)
order by id;

CRTL C1 C2 C3 RESULT
---------- ---------- ---------- ---------- ----------
1 12 -1 -1 12
2 -1 7 4 19
2 -1 9 8 28
3 -1 5 7 35
1 18 2 3 18





(thanks to rob van wijk for this)

Oktober 21, 2006

Transferring files using the Oracle server

in Oracle 10G you can transport files over SQLNet and let the database manage the filetransfer. with this new feature, its possible to copy files on the local host and to put and get files from and to remote databases (transferring between databases). Source and target directories (as Oracle objects) has to exist and you use them with the filename as actual parameters for the plsql packe DBMS_FILE_TRANSFER to do the job.

connecting to Oracle without using the tnsnames or host method

new to te Oracle 10G SQLNet network is the possibility to connect directly to a database. An Entry in tnsnames.ora or sqlnet.ora is not needed. Syntax for this connect string is:

user/password@//host/servicename

You can use this with sqlplus or even when creating a database link within a database:

create ... database link .... using 'user/password@//host/servicename'

it works only for sqlnet over tcp/ip and with a listener on the default port. when using nondefault ports use ....@//host:port/servicename

August 17, 2006

Oracle Database File Size Limits

especially for both older operation systems and older oracle releases there exist limits which define a maximum size for a single database file.

an (older) 32bit-oracle limit is that a database file is only allowed to store a maximum of 4M (4194303) oracle database blocks (DB_BLOCK_SIZE). This is (unsigned) 32Bit minus some overhead. 64bit releases (e.g. 10.1 for Solaris > 2.5) are not limited in this way. this explains why there is a limit of 32GB for dbs on most Oracle 8 Systems (if OS support 32 GB files) as 4M * Blocksize (8K is often the case) gives 32 GB (1k = 1024). In Oracle 10G these size-limited files belong to "smallfile" tablespaces, in pre-10G versions, only this type of tablepace was available. Bigfile tablespaces are new in 10G, are allowed to have only one database file but the filesize is (nearly) unlimited. For a tablespaces blocksize of 8K it is 32TB.

Some OS Limits are:
FAT 4GB
NTFS 16Tb
Solaris < 2.6 2 GB
Solaris > 2.5 1 TB

If you have access to Oracle Metalink, there exists some Oracle Notes for related Problems, see:
Note:62409.1 Solaris
Note:62427.1 2 GB File limits in Oracle
Note:67421.1 Problem with >4 GB on Oracle 8 / NT
Note:112011.1 Autoextend

Mai 17, 2006

Oracle 10G DB Control Reinstall on 10G R1 and R2

Reinstallation is different in R1 and R2 (on Windows xp)

on R1:
uninstall with the cmdline tool emca:
emca -x SID
reinstall again with java based DB Config Agent:
dbca

in spite of a "sys as sysdba" login in sqlplus is working,
after installation of the DB Control there may be the
need to do a alter user sys identified by xxx (same password)
to make the login work in the DB Control.

on R2 all can be done with emca:
emca -deconfig dbcontrol db -repos drop
install again goes with:
emca -config dbcontrol db -repos create

for additional infos see
Configuring Database Control with EMCA

Oracle 10 G DB Control : Changing Language in GUI

oracle db control is a webbased application for (advanced) configuration and
administration and tuning of a single oracle instance. changing the language of the webapp for is very simple - it has nothing to do with NLS_LANGUAGE settings. a reinstall or re-applying of a configuration via emctl or emca or dbca is not needed.
all to do is to change the language _clientside_ in the browser settings .)
this works immediate, even without a restart of the browser.

Mai 16, 2006

Reason why Oracle is slow

during exploring new features in Oracle 10G Release 2 i found by accident
the proof why oracle is so slow (in spite of this is not a new feature)


SQL> select parameter_name, parameter_value, description
from dba_advisor_def_parameters
where advisor_name = 'ADDM' and parameter_name like 'DBIO%';

PARAMETER_NAME PARAMETER_VALUE
---------------------- -----------------
DESCRIPTION
----------------------------------------
DBIO_EXPECTED 10000
Die erwartete Antwortzeit in Millisekunden
f³r das Lesen eines Datenblocks aus einer Datendatei




(this is translated: the expected average response
in milliseconds for reading a datablock from a database file)

.)

Mai 10, 2006

googlemail as an external web-harddrive

googlemail offers 2.5 gb free storage. as noone uses this for mails someone got the idea to use it as a filestorage medium as its possible to save attachments in drafts. the following small tool implements a virtual drive in windows explorer this is a fine tool to share some file between home and work location:

http://www.viksoe.dk/gmail

Oktober 20, 2005

[Java] JAXP Parser Implementations

recently i had problems processing large xml files. jdk 1.4.2 is in use on all platforms. our customer uses a sun fire solaris system, development takes place on a w2000 eclipse 3.2. errormessage goes like this:
org.xml.sax.SAXParseException: Parser has reached the entity expansion limit "64,000"
i read some documentation and soon discovered the system property "entityExpansionLimit". with this its possible to set the limit on a large value; the default is 64K. but to my surprise it worked on windows2000 but not on the customers solaris system. i read about that jdk 1.4.2 is shipped with xerces instead of the crimson as parser, and for xerces the above system property is defined to work. i checked the endorsed directory and verified the nonexistance of a jaxp.properties. so in both environments the saxparserfactory returns the default implementation. on w2000 this is an org.apache.xerces.jaxp.SAXParserImpl, and on solaris, a crimson () is in use. as a solution, i provided a xerces.jar on the classpath and forced its usage with the help of the systemproperty javax.xml.parsers.SAXParserFactory. for xerces and crimson its possible to provide the value org.apache.xerces.jaxp.SAXParserFactoryImpl or org.apache.crimson.jaxp.
SAXParserFactoryImpl. for DOM and XSLT the properties javax.xml.parsers.DocumentBuilderFactory or javax.xml.transformer.TransformerFactory

September 29, 2005

[german] Interview mit Götz Werner

Dieses Interview mit Götz Werner, der Chef der Drogeriemarktkette DM, ist es wert gelesen zu werden

Alle Politiker sind sich einig: Das wichtigste in Deutschland ist die
Bekämpfung der Arbeitslosigkeit. Die Drogeriemarktkette DM ist ein
Unternehmen, bei dem seit Jahren neue Stellen geschaffen werden. Doch im
Gespräch mit Sönke Iwersen überrascht der Gründer Götz Werner mit
ungewohnten Ansichten.

Herr Werner, wie wichtig ist Ihnen die Schaffung neuer Arbeitsplätze?


Überhaupt nicht wichtig. Sonst wäre ich ja ein schlechter Unternehmer.
Als solcher habe ich meine Aufgaben zu erfüllen.
Wäre es nicht Ihre vornehmste Aufgabe, Arbeitsplätze zu schaffen?
Ich muss wirklich sagen, dass ich dieses Gerede von der Schaffung neuer
Arbeitsplätze langsam nicht mehr hören kann. Warum wird dem so wenig
widersprochen? Die Wirtschaft hat nicht die Aufgabe, Arbeitsplätze zu
schaffen. Im Gegenteil. Die Aufgabe der Wirtschaft ist es, die Menschen
von der Arbeit zu befreien. Und das ist uns in den letzten 50 Jahren ja
auch grandios gelungen.

Sie finden Arbeitslosigkeit grandios?


Moment. Noch keine Generation in Deutschland musste jemals so wenig
arbeiten und hatte gleichzeitig einen solchen Lebensstandard wie wir
heute. Als ich ins Gymnasium ging, hatten zwei Kinder in der Klasse
einen Fernseher und bei zwei Kindern in der Klasse hatten die Eltern ein
Auto. Bei meinen Kindern heute gibt es wahrscheinlich zwei Elternhäuser,
die keine zwei Autos haben. Und vielleicht zwei Elternhäuser, die keine
zwei Fernseher haben.
Aber der Wohlstand kommt doch von Arbeit, nicht von Arbeitslosigkeit.
Wie schaffen wir es, dass wieder mehr Arbeitsplätze entstehen?
Das ist nicht die Frage, die sich ein Unternehmer stellt. Kein
Unternehmer überlegt sich morgens, wenn er in den Laden kommt: Wie kann
ich heute möglichst viele Menschen beschäftigen? Allein die Vorstellung
ist schon absurd.
Die Frage lautet umgekehrt: Wie kann ich mit einem möglichst geringen
Aufwand an Zeit und Ressourcen möglichst viel für meine Kunden
erreichen? Wie kann ich den Laden besser organisieren? Und besser
organisieren heißt immer, Arbeit einzusparen. Das ist ein absolutes
unternehmerisches Prinzip.
Aber Herr Werner. Sie haben bei DM in den letzten Jahren doch selbst
tausende von Arbeitsplätzen geschaffen.
Ja schon. Aber unser Unternehmen ist deswegen erfolgreich, weil es
produktiver ist als andere. Weil es produktiver ist, wächst es. Weil es
wächst, schafft es Arbeitsplätze. Aber die gehen zu Lasten der
Arbeitsplätze bei den Unternehmen, die weniger produktiv sind.
Volkswirtschaftlich gesehen führt Erfolg bei gesättigten Märkten immer
zum Abbau von Arbeitsplätzen.

Sie halten fünf Millionen Arbeitslose also für einen Beweis der
Leistungsfähigkeit der deutschen Wirtschaft?


Zumindest ist es ein Ausdruck der Produktivitätsentwicklung. Und eine
Produktivitätsentwicklung ist immer ein Fortschritt. Ich erinnere mich
daran, dass meine Mutter 1959 einen VW-Käfer bestellt hat. Da betrug die
Lieferzeit 13 Monate. Können Sie sich das heute noch vorstellen?
Kaum.
Sehen Sie. Und Anfang der 70er Jahre warb die Post mit dem Motto: Fasse
dich kurz. Der Grund war, dass ständig die Leitungen belegt waren und
die Leute sich die Finger wund wählten. Stellen Sie sich mal vor, die
Telekom oder Vodafone würden heute mit solchen Werbesprüchen kommen. Das
ist gar nicht denkbar.
Sie wollen sagen, dass es uns heute besser geht als früher.
Wir leben quasi in paradiesischen Zuständen. Denn wir sind heute in der
Lage, weit mehr zu produzieren, als wir sinnvoll verbrauchen können. Ein
Beispiel: Wäre die Wiedervereinigung 20 Jahre früher gekommen, hätte es
in Deutschland riesige Mangelerscheinungen gegeben. 1970 war die
Wirtschaft noch nicht so weit, mal eben 17 Millionen Menschen
mitzuversorgen. 1990 funktionierte das doch erstaunlich glatt. Niemand
im Westen musste einen Mangel erleben.

Dafür sind heute im Osten 20 Prozent der Menschen arbeitslos.

Ja, schlimm genug. Aber diese ganze Diskussion um die Bekämpfung der
Arbeitslosigkeit führt ins Nichts. Und jeder, der etwas von Wirtschaft
versteht, weiß doch eines: Die Zeit der Massenarbeit ist vorbei. Ich war
gerade in Island. Doch hat mir ein Fischer erzählt, dass die Isländer
heute dank Fabrikschiffen mit einem Viertel der Arbeiter vier mal so
viel Fisch produzieren wie vor 30 Jahren. Verstehen Sie? 75 Prozent der
Leute werden einfach nicht mehr gebraucht. Solche Beispiele gibt es
überall. Unsere Fähigkeit, Dinge zu produzieren, übersteigt unseren
Bedarf, Dinge zu konsumieren. Das ist eine ganz einfache Tatsache, und
keine Arbeitsmarktreform kann daran etwas ändern.

Trotzdem fordern Politiker, Wirtschaftsverbände und Gewerkschaften
ständig bessere Rahmenbedingungen, damit mehr Arbeitsplätze entstehen
können.


Ich weiß. Aber wir müssen uns doch fragen: Was ist eigentlich die
Aufgabe der Wirtschaft? Es gibt zwei Aufgaben.
Die erste: Sie muss die Menschen mit Gütern und Dienstleistungen
versorgen. Und nie in der Geschichte hat die Wirtschaft diese Aufgabe so
gut erfüllt wie heute. Wir sehen doch den totalen Überfluss. Obwohl die
meisten Fabriken längst nicht ausgelastet sind, wird alles produziert,
was man sich wünschen kann.
Produziert schon. Aber die Leute haben nicht genug Geld, es zu kaufen.
Aha! Jetzt kommen wir zur zweiten Aufgabe: Die Wirtschaft muss die Güter
nicht nur produzieren. Sie muss die Menschen auch mit ausreichend Geld
ausstatten, um zu konsumieren.

Ausstatten? Für Geld muss man arbeiten.

Ja, ja. Und wer nicht arbeitet, soll auch nicht essen, nicht wahr?
Dieses Denken sitzt immer noch tief in den Köpfen. Aber damit kommen wir
heute nicht mehr weiter.

Also wollen Sie das Geld einfach verteilen? Das ist doch naiv.

Meinen Sie? Lassen Sie mich bitte auf folgendes Phänomen hinweisen:
Warum gehen in Deutschland Baufirmen zu Grunde, obwohl es im Straßenbau
dringenden Bedarf gibt und wir die Leistung erbringen könnten?

Weil der Staat kein Geld hat, die Firmen zu bezahlen.

Ja. Aber dieser Irrtum kommt zu Stande, weil alles immer durch den
Geldschleier gesehen wird. Der Lebensstandard einer Gesellschaft hängt
doch davon ab, wie viele Güter sie produzieren kann. Nicht davon, wie
viele sie finanzieren kann.

Nicht?

Nein. Nehmen Sie die frühere DDR. Dort gab es Geld im Überfluss, aber
man konnte sich nur sehr wenig kaufen. Also was ist wichtiger: Das Geld?
Oder die Güter?
Was also schlagen Sie vor? Die Maschinen arbeiten, und der Staat
verteilt das Geld, damit die Bürger konsumieren können?
So ähnlich. Wir brauchen das bedingungslose Bürgergeld. Eine Lebensrente
für jeden Bürger. Selbstverständlich können solche Veränderungen nur
schrittweise über einen längeren Zeitraum eingeführt werden.

Wie hoch soll dieses Bürgergeld denn sein?

Hoch genug, um die Grundbedürfnisse zu decken. 1300 bis 1500 Euro.
Schöne Idee.

Und wie wird das finanziert? Sagen Sie jetzt bitte nicht,
wir brauchen mehr Steuern.


Keine Angst. Ich bin dafür, alle Steuern abzuschaffen. Bis auf eine: die
Mehrwertsteuer.

Und wie hoch soll die dann sein?

Das könnten bis zu 48 Prozent sein.
Sie machen Witze.
Nein. Zählen Sie doch mal alle Steuern und Sozialleistungen zusammen. Da
haben wir doch schon eine Staatsquote von rund 48 Prozent. Wenn die nur
noch über die Mehrwertsteuer zu finanzieren wäre, hätte das riesige
Vorteile.

Welche denn?

Die Mehrwertsteuer ist die einzige Steuer, die den Wertschöpfungsvorgang
nicht behindert, nicht bremst, nicht verzerrt. Das heißt: die ganze
Produktion wird steuerfrei gehalten und es kann unbehindert investiert
werden.

Also noch mehr Entlastung für die Unternehmen und noch mehr Belastung
für die Verbraucher?


Nein. Einfach mehr Klarheit und mehr Fairness. Ich weiß, dass Politiker
unterschiedlichster Couleur fordern: Wir müssen die Reichen besteuern,
die Unternehmen müssen wir besteuern und damit den kleinen Mann
entlasten. Das ist eigentlich eine Lüge. Warum? Weil Unternehmer und
Unternehmen faktisch keine Steuern bezahlen.

Da werden Ihnen einige Unternehmerkollegen widersprechen.

Jammern gehört zum Handwerk. Aber jeder Unternehmer weiß, was man mit
Steuern macht: Man muss sie einkalkulieren.
Alle Steuern, die die Unternehmen zahlen, fließen in die Preise für die
Produkte ein. Letzten Endes zahlt immer der Verbraucher.

Was wäre also der Vorteil, alle Steuern in der Mehrwertsteuer
zusammenzufassen?


Na, der ganze gewaltige Verwaltungsapparat des Staates würde
zusammenschnurren. Denken Sie mal daran, wie viele Beamte ihre Zeit
damit verschwenden, die Steuern zu erheben, auszurechnen und zu
überprüfen. Das wäre alles überflüssig.

Welche anderen Vorteile hätte Ihr Plan?

Dass die Importe endlich mal richtig besteuert werden. Die billigen
Textilien aus China oder Rumänien kommen doch nur so billig hier an,
weil sie nur mit einer Mehrwertsteuer von 16 Prozent belastet sind. In
jedem Produkt stecken Infrastrukturkosten. Aber die Infrastruktur in
Deutschland ist natürlich teurer als die in China. Anders herum würden
die deutschen Exporte extrem attraktiv, weil sie von Steuern völlig
unbelastet wären. Außerdem würden die Arbeitskosten extrem sinken, weil
ja das Bürgergeld auf die Einkommen angerechnet würde.

Wie soll das funktionieren?

Nehmen wir an, eine Krankenschwester verdient 2500 Euro. Nach Abzug des
Bürgergeldes von 1300 Euro müsste das Krankenhaus ihr noch 1200 Euro
bezahlen. Sie hätte danach gleich viel, aber ihre Arbeitsleistung wäre
für das Krankenhaus viel leichter zu finanzieren. Das Bürgergeld würde
die arbeitsintensiven Güter und Dienstleistungen entlasten und dadurch
den Arbeitsmarkt enorm beleben. Insgesamt würden die Preise dadurch
gleich bleiben, denn der Staat müsste ja das zu zahlende Bürgergeld über
die Mehrwertsteuer wieder refinanzieren.

Aber wer wird denn in Zukunft noch arbeiten, wenn er für 1500 Euro auch
zu Hause bleiben kann?


Sie unterschätzen den immateriellen Wert der Arbeit. Viele Menschen
haben sehr viel Spaß an ihrer Aufgabe. Denken Sie auch an alle sozialen
Berufe und die ganze Kulturarbeit. Da gibt es einen riesigen Bedarf in
der Gesellschaft, der endlich finanzierbar wäre.

Und die langweiligen, die unangenehmen Jobs?

Die müssten dann eben höher entlohnt werden, wenn wir sie benötigen.
Natürlich wird es dann zukünftig Berufe und auch Unternehmen geben,
denen es schwer fallen wird, Menschen zu finden. Warum? Weil ja die
Menschen dann nicht mehr arbeiten werden, weil sie müssen, sondern weil
sie in ihrer Arbeit eine Sinnerfüllung erleben. Und auch, weil es ihnen
Spaß macht.

Herr Werner, alle sprechen von der Krise. Wer Ihnen zuhört, könnte
denken, es geht Deutschland ausgezeichnet.


Das stimmt ja auch. Unser Land hat noch nie so viel Wohlstand produziert
wie heute. Wir haben nur Schwierigkeiten, den Wohlstand zu verteilen.
Das sind wir einfach nicht gewohnt.

Also keine Krise?

Jedenfalls keine Wirtschaftskrise. Die Frage, die mich wirklich
umtreibt, ist eine andere. Wir steuern auf eine Gesellschaft zu, in der
die Arbeit verschwindet. Und die Frage ist nur, was die Menschen dann
alle mit ihrer Zeit anfangen. Das ist eine Kulturfrage. Das Problem, das
wir haben, liegt nicht auf dem Arbeitsmarkt sondern eigentlich in der
Kultur. Leider ist dieses Thema im Bewusstsein der Gesellschaft kaum
vorhanden. Aber genau hier müssen wir ansetzen.

August 24, 2005

J2EE CMS Magnolia

magnolia is a open source j2ee based enterprise cms.
i tried Version 2.1 rc4 and during one of the first actions i had was trouble changing default passwords. escpecially for superuser. seems to be buggy; workaround was to delete and recreate user superuser and to activate. there is some documentation available but lots of issues are missing. its then time consuming to find things out. also found no answers to many newbie questions i had e.g. how things work generally. i also checked wiki and mailinglist archives for this. actually a problem is how to change / customize layout of the navigation menu. another minus is the (imo unneccessary) use of advanced jsp coding techniques (EL, jstl, custom taglibs). seems to be a quite (too ?) complex system. after installation (unpacked war files) and activation of 2 helloworld pages there are 77862 files under tomcat webapps (!!). Nothing more to say. Maybe i take a look at opencms.

Juni 28, 2005

Jakarta Velocity Tips

i collected some helpful tips after some weeks of coding using the jarkarta
velocity template engine. See theVelocity Homepage for Docs aso. These tips require some knowledge within the velocity template language (VTL)

  • a "Quiet Reference Notation" produces an emtpy String in case of a non existance which evaluates to true if used in an if statement. Snippet: #if($!value) ...
  • this init expression has a correct syntax, produces no runtime error but seems to leave actual values persistent for several parse calls. #set(${type}=false)
  • A nullvalue assignment preserves the original value as an assigment does not take place. Example: #set($type=$tool.getValueFor($key)). an explicit init (false) has to be done for $type before to make the code robust. especially in large files where $type is used a lot and when many parse calls take place upon the same vm-template such cases are likely to produce an error
  • there are some settings which affect velocity macros during runtime. the default settings causes macros to be loaded as global and subsequent macro definitions (e.g. from other templates) are rejected if the name is the same. these events are usually logged in the velocity log file.
  • errors during if-evaluations occurr when different objects are to be compared (e.g. Boolean and String). these events are also logged but rendering of the templates goes on.
  • its important to use blanks if you do some arithmetics. For example #set($var=$old+1) is wrong; #set($var=$old + 1) does a correct job.

März 15, 2005

Non-matching Regexps

I used String.split(String regexp) a lot to do some String splittings into String[] Arrays. The elements of the array are build around the maching portions of the original string. This leads maybe to the problem that some matched characters are not included. If e.g. a requirement is to split around a semikolon when uppercase characters are following this is exactly the case. The first uppercase character is not included in the array element. To enable this, the use of a non-capturing group is appropriate.
Literature mention this as zerolength noncapturing groups with positive or negative lookahead/lookbehinds. In the above case (split around a semikolon but only when followed by an uppercase character) the syntax for a lookahead has to be used; and because of the uppercase character (which has not to be included in the match) can be expressed in a regexp in a positive way, we have to use a noncapturing positive lookahead - group.

Syntax for this is:
Y(?=X) Y ist the core regexp to split around and Y is the following regexp (assertion)

For some reasons, negated assertions are making problems. Because of this, a separate Syntax has to be used (a negative lookahead)

Y(!=X) this means regexp Y not followed by regexp X

For some more reading about this, the following URL provides excellent information
http://www.regular-expressions.info/lookaround.html

this leads to regexps like:

"[\\s/(:](?=\\w)|\"(?=[A-Z])|\\-(?!\\s)";

(double escaped because this is a java-string-literal)

Februar 13, 2005

Eclipse3 - Jar Export Wizard, no Main Class

the export wizard to generate executable jarfiles seems not to be very mature in Eclipse3. there are several timeconsuming problems:

  1. no class is presented in the dialog to select the main class. i checked all settings, but found no solution. a possible cause is maybe when package directories have been created using "new Folder" instead of "new package". finally i set up the complete project definition in a new project in the workspace and moved all resourcefiles.
  2. compile errors during the the jarfile generation are reported, but the cause is not reported. in my case, no errors are reported in the projectworkspace (even after complete rebuilds) but jargeneration signals some compile errors.

Maybe it is better to build the jarfile by hand using jar -cvf etc.

Januar 20, 2005

Cvs Keyword Substitution in Javadoc

its possible to use cvs keywords within javadoc comments.
when you submit your file, cvs fills those placeholders.
but this is only the case for ascii file submission.
with this, cvs comments entered with eclipse or wincvs are
not hidden in the cvs repository. This is possible for placeholders
like author, revision, log comments etc.
this works too in real code:

private static final String VERSIONCVS = "$Revision$";

to generate javadoc class comments:

......
* @author BGaths
* @version $Revision$
*
* Log:
*
* $Log$
*
*/
public class Suche extends DetailAction {
.....


* characters are embedded and generated in a correkt way.
after 2 commits its like:


*
* @version $Revision: 1.3 $
*
* Log:
*
* $Log: ListeCwf.java,v $
* Revision 1.3 2005/01/19 14:35:12 BGaths
* table header text geändert
*
* Revision 1.2 2005/01/19 10:00:06 BGaths
* erweiterung der Liste, anzeige der Spalten
* fuer vertr.wuerdigOnix, vertr.w.Verlag u. verwertungsrecht
*
*
*/
public class ListeCwf extends ListeAction {

November 19, 2004

Misc

Java - Swing Window Closing

Swing Application JFrame - in case of a "windowClosing": if you forgot to implement a WindowListener to react in a correct way (eg. with System.exit), you notice no unusual behaviour, the Window closes but Resources are not deallocated. finally this "memory leak" leads to a blue screen because of massive memory allocation (on my W2000 PC). Default behaviour on a JFrame-windowclose is to hide the Frame (HIDE_ON_CLOSE), but no deallocation takes place - the VM is still running.

There are several options for an application to exit, when you set DISPOSE_ON_CLOSE or EXIT_ON_CLOSE the window (jframe) and VM terminates in case of a window closing event. (Whether a Windowlistener which reacts on a windowclosing event is present or not).

But it is usual to confirm a program exit. I noticed two ways for this:

- set setDefaultCloseOperation(DO_NOTHING_ON_CLOSE) for your frame and implement a windowlistener. within you can popup a confirmation dialog an do a system.exit or dispose() call

- set DISPOSE_ON_CLOSE and instead of writing a windowlistener overwrite dispose(). if an exit is required a call to super.dispose() does dispose all child components and terminates the VM - when there are no more active threads.

a dispose call only terminates the vm if no other window is displayable.

a VM-terminating system.exit call is not suitable if your application is used as an embedded component (e.g. a subprogram in its own window). if this is the case you have to work with dispose() for closing your subapplication. As the main app is still active, dispose does not terminate the VM and leaves your disposed frame in an usable state. a pack() and show() call restarts your subapplication.

sometimes a dispose call does not terminate the vm in spite of your application is the only one. check out if there are no more active threads. if this is ok, maybe you used an JOptionPane without setting the parent component. if this is the case, then the vm may not terminate !

VM terminates:

public void dispose() {
int n = JOptionPane.showOptionDialog(this,...
super.dispose();
}


VM does NOT terminate:

public void dispose() {
int n = JOptionPane.showOptionDialog(null,...
super.dispose();
}



Java - Jakarta Commons CLI.

If you use a PosixParser, you are safe when using only single char options. When you are using "longopts" the api allows a recognition, but argument value retrieval delivers not accurate. e.g. for "-outputdir temp" you get "utputdir temp". As a rule of thumb, longopt-options without arguments are quite usable, without arguments its better to use the default (short) single-char-option.