Archives for the Month of March, 2007

Command-line debugging with Java

Steps to debug Java apps in stone-age style:

Run your program with additional switches
java -Xdebug -Xrunjdwp:transport=dt_shmem,server=y,address=MyAppName,suspend=n -cp . test

Run the command line debugger
bin/jdb.exe -connect com.sun.jdi.SharedMemoryAttach:name=MyAppName
Tell the debugger where the sources aresourcepath C:/Cygwin/Home/Chui
Show list of threads, suspend the threads, display call stack, and step through code

$ bin/jdb.exe -connect com.sun.jdi.SharedMemoryAttach:name=MyAppName
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
Initializing jdb [...]

Returning Identity Column of Autoincrement Fields

Issuing an Insert command on an ObjectDataSource typically requires two database calls:
1) INSERT INTO mytable ….
2) SELECT @@IDENTITY
If you are prototyping against Access databases, one problem that becomes quickly apparent is that OleDb providers do not support multiple SQL statements. So you can’t do set the following commandtext in a DataTableAdapter method:
INSERT INTO mytable ….;
SELECT [...]

Lack of Humane Interaction, not Anonymity is the cause of bad behaviour

Story about death threat against blogger Kathy Sierra is making headlines right now, but I’d argue that it’s nothing to do with anonymity, but classic group think and group behaviour. It’s the same kind of thinking that led to tacit support among the general public for Nazism in Germany.
Conditions for this are: you [...]

Netbeans Autosubmit Drop Down Boxes

The immediate attribute against the dropdown box is a bit misleading. This is wholly different from the autopostback=”true” attribute on ASP.net.
With JSF, you need to write your own javascript, or use the IDE context menu to write one for you.

Here’s a code sample showing how to change the contents of a second dropdown [...]

CachedRowSetDataProvider Bug when removeRow and appendRow called without commitChanges

Here’s the test case and stack trace

public String btnTest_action() {

getMaintdayitemDataProvider().removeRow(getMaintdayitemDataProvider().getCursorRow());
getMaintdayitemDataProvider().appendRow();
getMaintdayitemDataProvider().cursorLast(); //
return null;
}

java.lang.IllegalArgumentException: CachedRowSetRowKey[2]
[...]

Netbeans Visual Web Selecting Rows

The UI presentation layer doesn’t hold state about which rows were selected.
Winston Prakash outlines how selecting a single row in Netbeans JSF table can be done, but it was a little roundabout.
Here’s a simpler take on it:
Bind a TableRowGroup’s selected attribute to a property on your page.

<ui:tableRowGroup
[...]

Changing up the datasource name in a Netbeans project

In your personal directory, there is a Netbeans configuration file called context.xml, it has a list of datasources and their jdbc URLs
C:\Documents And Settings\Chui\.netbeans\5.5\context.xml

<context name=”java:comp”>
<context name=”env”>
<context name=”jdbc”>
<object name=”TravelPack” class=”com.sun.rave.sql.DesignTimeDataSource”>
[...]

Clustered Hosting Solutions

It seems like 2007 is going to be year when web hosters move en-masse to virtualizating their shared-server. In the past, virtual hosting is simply the practice of hosting lots of websites on a single box, and a web hoster may run tens of boxes.
With clustered hosting, every website is served by every box, [...]

NetBeans, Derby, JSF and Jetty

Netbeans 5.5 has made developing web apps almost as easy as Microsoft’s flagship Visual Studio. However, there are still elements which can still be hard to figure out. Here are some personal notes:
1. The Derby databases are located in your home directory, under .netbeans-derby. (In Netbeans, Tools, Java DB Database, Create Java DB Database … [...]