Archives for the ‘Java’ Category

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 [...]

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”>
[...]

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 … [...]

Full Text Indexing in Ruby is Faster than Java

Jim Wiseman John Wiseman, who is porting Ferret to Lisp, reports on the blazing performance of Ferret.
(Ferret was originally a port of Lucene, but recent alteration to the file format has increased performence 5x over GCJ, and then the author ported to C to get an order of magnitude improvement.)
The moral of the story is [...]

ActiveX is the weakest link

Once in a while, it is gratifying to see how Microsoft’s embrace and extend comes back and bite them in the a***. Take Microsoft’s Internet Explorer, back when MS was defending their Windows OS turf against Netscape’s Browser OS. Microsoft, in their infinite wisdom, decided to extend the browser to include ActiveX applets. Now there is already a large base of ActiveX components on the Windows platform, so naturally, adding ActiveX components to web browsers would help entrench Microsoft’s dominance on the client side right?

As history has turned out, the answer is a resounding NO.

JRuby on Rails

This piece of news about JRuby on Rails ought to make James McGovern sit up.
Incidentally, I have been experimenting with a Rails clone in PHP called Cake PHP. It was pleasant, and remarkably close to Rails. Given how widely PHP is supported in the web hosting world, Cake seems to give a PHP developer a [...]

Transporting Data in Web Services

Jim Waldo on language independent means of transporting data:
First of all, it means that you need to have a language-independent mechanism for passing data from one place to another. But there is no more a language-independent way of expressing data than there is a language-independent way of expressing objects. If I tell you that a [...]

A forum with no members

Netbeans has a code colloboration feature and integration into real-time public chat rooms. Let’s see, I signed up an account and browsed the list of public discussions.
A big list shows up and signing into a few of them turned out to be empty.
How’s a new guy supposed to find some help?
A list of [...]

JDBC Connection URLs for 22 Databases

Here is a non-exhaustive list of JDBC connection URLs for various databases. Corrections welcome!
Microsoft SQL Server JDBC connection URL

jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind
com.microsoft.jdbc.sqlserver.SQLServerDriver
msbase.jar;mssqlserver.jar;msutil.jar
downloadl

Microsoft SQL Server 2005 JDBC connection URL

jdbc:sqlserver://serverName\instance:port[;user=value][;password=value][;property=value]
com.microsoft.sqlserver.jdbc.SQLServerDriver
sqljdbc.jar
download SQL Server 2005 driver

Microsoft SQL Server (JTurbo) JDBC connection URL
jdbc:JTurbo://<HOST>:<PORT>/<DB>
com.ashna.jturbo.driver.Driver

Microsoft SQL Server (Sprinta) JDBC connection URL
jdbc:inetdae7:<HOST>:<PORT>?database=<DB>
com.inet.tds.TdsDrive
download