Skip to content

www.rolfje.com

Tag: programming

SVN is missing the point?

Posted on 2008-02-16 By rolfje 19 Comments on SVN is missing the point?

Our company was using Rational Clearcase for version control about 6 years ago. The developers decided it was way to clunky, error prone and WAY too expensive. We introduced CVS and it has been working fine for a few years now. CVS is widely known, stable and simple. I looked into using SVN a few years ago but the clients were unusable at that time. This year, the SVN discussion came to life again and some of my collegues started playing with it after I mentioned it as being a step forward from CVS.

Read More “SVN is missing the point?” »

Software

Essential Color Design Tool

Posted on 2007-10-15 By rolfje 1 Comment on Essential Color Design Tool

For those people out there designing user interfaces, web frontends or anything else displayed on a screen: About 8% of all males are color blind. This could mean that because of a simple color choice, 8% of your target audience (customers) could have serious difficulty in using your design. 5% of all males can’t distinguish green from red, although they are regarded as high contrast to eachother.

Do you want to test how your design looks to colorblind people? Now you can, with Color Oracle, a tool for Mac OSX and Windows which transposes the colors of your screen to reflect what it would look like if you were color blind. In fact, it can simulate 3 different kinds of color blindness.

From the site: “Color Oracle takes the guesswork out of designing for color blindness by showing you in real time what people with common color vision impairments will see. Color Oracle applies a full screen color filter to art you are designing – independently of the software that you are using. Eight percent of all males are affected by color vision impairement – make sure that your graphical work is readable by the widest possible audience.”

Software

Programmer Personality Test

Posted on 2007-06-06 By rolfje No Comments on Programmer Personality Test

Just found this funny page where you can take a Programmer Personality Check.

My programmer personality type is DHTB, which is explained as follows:

You’re a Doer.
You are very quick at getting tasks done. You believe the outcome is the most important part of a task and the faster you can reach that outcome the better. After all, time is money.

You like coding at a High level.
The world is made up of objects and components, you should create your programs in the same way.

You work best in a Team.
A good group is better than the sum of it’s parts. The only thing better than a genius programmer is a cohesive group of genius programmers.

You are a liBeral programmer.
Programming is a complex task and you should use white space and comments as freely as possible to help simplify the task. We’re not writing on paper anymore so we can take up as much room as we need.

Software

Parameter List Too Long

Posted on 2007-04-17 By rolfje 1 Comment on Parameter List Too Long

If your are “fortunate” enough to have to delete a lot of file from a directory on a Unix system, you are likely to encounter the “Parameter List Too Long” problem. This problem is caused by Unix trying to replace the “*” you just used by all names in the directory. This list is then passed to the rm command, which complains that it can not handle that much parameters.

To get around this limitation, you have a couple of options:

Delete all files in the current directory
By far the fastest and most compatible way to delete all files in the current directory without recursing into subdirectories is:
ls | xargs rm
This is the fastest command, because xargs makes sure the maximum allowed number of parameters is passed to rm, resulting in fewer calls/startups to rm.

Delete all files in the current directory and all subdirectories
To delete files not only from the current, but also from all subdirectories, use
find . -name "*" -exec rm -rf {} \;
This is somewhat slower, since rm is executed seperately for each file.

Above commands are tested on AIX and Linux.

Software

Thoughts on Widgets, Gadgets, Screenlets

Posted on 2007-04-11 By rolfje No Comments on Thoughts on Widgets, Gadgets, Screenlets

Just now, I was listening to the Java Posse podcast about the ab5k screenlet framework for Java, and I am finally convinced that software developers are a bunch of crazy, unrealistic, memory-hungry, cpu cycle stealers and by lack of normal people telling them otherwise are proud of it, too. The problem? Look at this list (no particular order):

  • Linux screenlets or applets
  • Windows Sidebar Gadgets
  • Apple Dashboard Widgets
  • Google Desktop Gadgets
  • Yahoo Widgets
  • and recently added: ab5k.org java screenlets

Read More “Thoughts on Widgets, Gadgets, Screenlets” »

Software

Java 5 BigDecimal.toString() and Oracle 10g jdbc

Posted on 2007-01-31 By rolfje 2 Comments on Java 5 BigDecimal.toString() and Oracle 10g jdbc

Yesterday a collegue of mine discovered a very ugly problem when storing BigDecimals from a Java 1.5 program into an Oracle 10g database. Not by experience, but by reading the article at http://www.javalobby.org/java/forums/t88158.html. We had not encountered the problem ourselves, but when passing the dredded 12500000 value to the BigDecimal constructor and passing it to the database, we discovered that we too were affected by this bug. So off I went to search a solution.

The root of the problem lies not only in the fact that the BigDecimal.toString() method behaviour has changed in Java 1.5, but also the way BigDecimals are constructed. The Oracle driver relies on a specific formatting of the BigDecimal.toString() method, and can not handle the output of the “new and improved” BigDecimal in Java 1.5. All discussions about not using toString() for passing values and flaming Oracle and/or Sun aside, we have no option but to fix the problem right now. Oracle promised to fix this problem not sooner than in release 11g, so waiting is not an option.

Option 1: Overriding BigDecimal.toString()
In our project, we use Ibatis. This gives us a nice handle to implement our own BigDecimalTypeHandler, where we can choose to do anything to the BigDecimal before storing it into the database, and revert that when retrieving it from the databse. One of the options we thought of was to override the BigDecimal’s toString in an anonymous subclass inside our IbatisTypeHandler, like so:


public void setParameter(PreparedStatement ps, int i,
                        Object parameter, String jdbcType)
                        throws SQLException {
  BigDecimal colVal = new BigDecimal(
              ((BigDecimal)parameter).toPlainString()){
    public String toString(){
      return toPlainString();
    }
  };
  ps.setBigDecimal(i, colVal);
}

The anonymous subclass lets you add or change behaviour to an existing class without cluttering your codebase with a classfile which looks rather strange when places out of context. We tried various ways of locally changing the behaviour of BigDecimal to make it go into and out of the database in a way that our unittest would not know the difference, but at some point gave up. There is not really a good way to do this without compromising in scale or resolution in the conversion.

When using the setParameter described above, you will not get a situation where originalBigDecimal.equals(storedBigDecimal) returns true. In most cases this will not be a very big problem, since originalBigDecimal.subtract(storedBigDecimal) will always return 0.

If somebody thinks of a way to store BigDecimals into the database and retrieving them in a way it is totally transparent to the caller (compared to JDK 1.4 behaviour) please feel free to post it here.

Option 2: Loosing your BigDecimals

Perhaps this option had to be considered when thinking of using BigDecimals in the first place. BigDecimals are very awkward to calculate with, are relatively heavy both performance and memory wise. Very often they get converted to doubles before doing any calculations with them, which eliminates most of the reasons for using BigDecimals anyway.

The easy way to loose only those BigDecimals which get stored in the Database, rewrite the typeHandler you just created into the following:


public void setParameter(PreparedStatement ps, int i,
                        Object parameter, String jdbcType)
                        throws SQLException {
  throw new UnsupportedOperationException(
    "Oracle can not handle Java 5 BigDecimals properly");
}

Now, run all Unittest (you have unittests covering at least 80% of your software, don’t you?) and replace BigDecimals with other appropriate datatypes where you see the UnsupportedOperation popup.

Software

Lost Oracle SYS and SYSTEM password?

Posted on 2007-01-16 By rolfje 56 Comments on Lost Oracle SYS and SYSTEM password?

If your administration is as good as anybodies, you are bound to loose the not-so-frequently used password for the SYS and SYSTEM users of oracle. Here are a few ways I found to re-set those passwords:

Method 1: SQLPLUS (Tested on AIX Oracle 9.2.0.1.0)

Log into the database server as a user belonging to ‘dba’ [unix ] or ‘ora_dba’ [windows ] group , typically ‘oracle’, or an administrator on your windos machine. You are able to log into Oracle as SYS user, and change the SYSTEM password by doing the following:

$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.1.0 - Production on Mon Apr 5 15:32:09 2004

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> show user

USER is "SYS"

SQL> passw system
Changing password for system
New password:
Retype new password:
Password changed
SQL> quit

Next, we need to change the password of SYS:

$ sqlplus "/ as system"
SQL*Plus: Release 9.2.0.1.0 - Production on Mon Apr 5 15:36:45 2004

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where <logon>  ::= <username>[/<password>][@<connect_string>] | /
Enter user-name: system
Enter password:

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> passw sys
Changing password for sys
New password:
Retype new password:
Password changed
SQL> quit

You should now be able to log on the SYS and SYSTEM users, with the passwords you just typed in.

Method 2: Creating pwd file (Tested on Windows Oracle 8.1.7)

  1. Stop the Oracle service of the instance you want to change the passwords of.
  2. Find the PWD###.ora file for this instance, this is usuallly located atC:\oracle\ora81\database\, where ### is the SID of your database.
  3. rename the PWD###.ora file to PWD###.ora.bak for obvious safety reasons.
  4. Create a new pwd file by issuing the command:
    orapwd
    file=C:\oracle\ora81\database\PWD###.ora password=XXXXX
    where ### is the SID and XXXXX is the password you would like to use for the SYS and INTERNAL accounts.
  5. Start the Oracle service for the instance you just fixed. You should be able to get in with the SYS user and change other passwords from there.
Software

Ibatis Nullpointer calling stored procedure

Posted on 2006-11-07 By rolfje 1 Comment on Ibatis Nullpointer calling stored procedure
Today, a collegue of mine had a really strange nullpointer problem trying to call a stored procedure in an Oracle 10 database using iBATIS Java 2.2.0. What she had was a normal JavaBean, like so: 

package com.rolfje.foo
public class BarBean {
    private String barName;
    private Long barId;

    ... setters/getters here ...
}

A straightforward parametermap:

<parameterMap class="com.rolfje.foo.BarBean"
      id="barbeanMap">
   <parameter property="barName" />
   <parameter property="barId" />
</parameterMap>

and a straightforward procedure mapping:

<procedure id="insertBar" parameterMap="barbeanMap">
   {	call store_bar (
      ?,?)
   }
</procedure>

When trying to call the stored procedure, she got the following stacktrace:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation;
uncategorized SQLException for SQL [];
SQL state [null]; error code [0];
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException; nested exception is

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/rolfje/foo/sqlmaps/ParameterMap.xml.
--- The error occurred while applying a parameter map.
--- Check the barBeanMap.
--- Check the statement (update procedure failed).
--- Cause: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
   at ...executeQueryWithCallback(GeneralStatement.java:188)
   at ...executeQueryForObject(GeneralStatement.java:104)
   at ...queryForObject(SqlMapExecutorDelegate.java:565)
...

After hours of staring at the problem, and comparing code with similar constructions from other projects, we decided to switch to the Oracle 9i thin driver to see if that would solve the problem. It didn’t, but there was an interesting development: The Oracle 9i driver actually gave us a decent error about not being able to parse the SQL statement. Which brings us to…

The solution:
We removed all layout from the procedure mapping, which resulted in:

<procedure id="insertBar" parameterMap="barbeanMap">
   {call store_bar (?,?)}
</procedure>

This solved the problem. Then we switched back to the Oracle 10i thin driver, and the problem was still gone. The problem lies in the TAB between the left curly bracket and the word “call”. Oracle can not handle this.To investigate this problem, we then also tried to insert <![CDATA[ ]]> around the procedure call, but as soon as there is a TAB between the { and the word “call” iBATIS will throw a NullPointer. The strange thing is that you can have spaces, newlines and tabs *anywhere* in the procedure mapping, as long as there is no TAB between the left curly and the word “call”.

Software

Welcome www.rolfje.com readers!

Posted on 2006-10-20 By rolfje No Comments on Welcome www.rolfje.com readers!

Because the update process of my old site was much more hassle than typing a post, I noticed that my blog was better maintained than my site. Therefore I have decided to redirect traffic to my domain (rolfje.com) to my blog. You can still find the original content of www.rolfje.com at http://www.xs4all.nl/~rrolfje/.

Read More “Welcome www.rolfje.com readers!” »

Uncategorized

Killing oracle sessions, the easy (JDBC) way.

Posted on 2006-02-23 By rolfje 2 Comments on Killing oracle sessions, the easy (JDBC) way.
Does Oracle complain about not being able to drop a table for a currently connected user, but you are sure you disconnected? Do the sessions “hang” in “inactive” state? Just log on as system, and execute the following query: 

SELECT
'ALTER SYSTEM KILL SESSION ''' || sid || ',' || serial# || '''; --',
       s.sid,
       s.serial#,
       s.osuser,
       s.username,
       s.program,
	status
FROM   v$session s
WHERE status = 'INACTIVE';

You will get a list of statements you need to execute (just copy-pase) to kill the inactive sessions. Don’t listen to the guys telling you to do intricate System Administrator stuff on a command prompt, just use any JDBC tool.

EDIT: Single query which also lists the kill command if the “alter system kill session” trick did not work:

SELECT
'ALTER SYSTEM KILL SESSION ''' || s.sid || ',' || s.serial# ||
       '''; -- kill -9 ' || p.spid,
       s.sid,
       s.serial#,
       p.spid,
       s.username,
       s.program,
       s.status
FROM   v$session s, v$process p
WHERE s.paddr = p.addr
  and (s.state='INACTIVE' or s.state='KILLED');

Thanks Bas en Jeroen!

Software

Posts navigation

Previous 1 … 4 5 6 Next
           

Recent Comments

  • rolfje on Methode Buijs uitgelegd
  • LinkedIn is at Peak Enshittifaction – Will Chatham's Blog on Linked-In not really Opt-in?
  • Hans j on 1N4148 diode as RF switch
  • Roaming Rhonda on DLNA on OSX, done right
  • Frans on How to fix a Krups XN2001 Nespresso machine

Tags

Anonimatron Apple backup design DIY DRM eclipse environment Fun gmail google hacking hamradio Hardware helicopter iphone ipod iTunes Java Keynote maven modelling motorcycle music news opinion oracle osx photo photography programming repair review security Software Steve Jobs T-Mobile technology Time Machine Ubuntu usability Utilities vacation windows Workshop

Categories

  • Apple (105)
  • Divorce (1)
  • Electronics (3)
  • Fun (57)
  • Games (7)
  • Hardware (72)
  • Microsoft (18)
  • Racing (14)
  • Software (134)
  • Uncategorized (65)
  • Workshop (20)

Archives

Copyright © 2025 www.rolfje.com.

Powered by PressBook WordPress theme