Archives for the ‘Java’ Category

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

Clojure symbol counting

One of the little things I found enjoyable while trying out Clojure was discovering the merge-with command. After counting the each of the subbranch and collecting the results in dictionaries, the dictionaries were merged together.

clojure.core/merge-with
([f & maps])
Returns a map that consists of the rest of the maps conj-ed onto
the first. [...]

A plan for learning clojure

I had printed out the list of functions and macros in the Clojure API page, and it filled out two A4 pages. Where to start though? I walked the entire clojure and clojure contrib directory and counted the number of function calls. Here are the top stats.

sym count len
clojure.core/list 3872 17
quote 2749 5
defn 1757 4
clojure.core/seq 1481 16
clojure.core/concat 1480 19
= 1074 1
let 1042 3
is 885 2
. 836 1
if 826 2
defmethod 431 9
def 407 3
complex 377 7
defn- 376 5
fn 356 2
first 346 5
defmacro 298 8
clojure.core/apply 264 18
deftest 257 7
str 252 3
when 244 4
imaginary 238 9
recur 237 5
apply 229 5
instance? 220 9
nil 217 3
and 214 3
next 208 4
cl-format 206 9
fn* 197 3
ns 194 2
map 193 3
:use 187 4
list 184 4
1 181 1
count 178 5
+ 169 1
seq 167 3
reduce 165 6
are 148 3
cons 143 4
println 141 7
or 141 2
not 135 3
loop 133 4
thrown? 127 7
* 127 1
conj 125 4
print 124 5
nth 124 3
- 116 1
doseq 114 5

Now, I have a study-plan.
Incidentally, waterfront IDE is quite [...]

JavaFX experiment

I was having a lot of problems getting the simplest test case below to run without throwing an odd exception:

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.ext.swing.SwingTextField;
import javafx.ext.swing.SwingButton;

Stage {
title : "MyApp"
scene: Scene {
width: 200
height: [...]

JavaFX Custom Cursors

Setting custom cursors with JavaFx is relatively straightforward, but for one little catch. Your image has to be 32×32. If you want a 16×16 icon, simply leave the rest of the image transparent.

import java.awt.Toolkit;
import javafx.scene.Cursor;
import javafx.scene.image.Image;

public class ColorChooser extends Cursor
{
public override function impl_getAWTCursor(): java.awt.Cursor {

[...]

JavaFX Introspection

Just sharing some code snippets for deserialization of JavaFX objects.

function getValueType(obj:Object,name:String):String
{
var context:FXLocal.Context=FXLocal.getContext();
var objectValue:FXLocal.ObjectValue = new FXLocal.ObjectValue(obj,context);
var cls:FXClassType = objectValue.getClassType();
var varType:FXType = cls.getVariable(name).getType();
println("{name} {varType}");
if (varType instanceof FXSequenceType)
{
[...]

JavaFX binding in sequences

I had a Group of circles, i.e.
var circles:Circle[];
var group:Group = Group { content: [circles] };
strangely, I couldn’t get newly inserted circles to render.
It turns out that you have to bind group.content to ensure that changes in circles are reflected in group.content.
Here’s a test routine.

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.stage.*;

var lines = for (i in [1..10])
[...]

Applet for Submitting Screenshot

Submitting screenshots through the web takes several steps more than it ought to. Firstly we have to paste it into mspaint.exe, save it to disk, only to then fiddle around with the File upload to look for the file again.
Another way to do it is via a signed applet. Unfortunately, the signed applet is unable [...]

A list of people doing interesting work on the JVM

Andrew Haley Zero, Shark – llvm code generators
Gary Benson RedHat. Zero and Shark
Volker Simonis – SAP JIT group, how to build HotSpot
Pekka Jato – JIT compiler for Java
Jevgeni Kabanov Class reloading using serialization to patch runtime instances
I’m sorry if I missed your name here. Please leave a comment here if you wish to be [...]

Database Patterns realized with AribaWeb

Take a look at aribaweb.org (viaTheServerSide).
AribaWeb is a 4GL RAD for web applications running on a Java stack.
It uses an approach described in data dictionaries as a database pattern to generate metadata-driven UI.
The Ariba toolset seems reasonably mature from the screencasts, although one has to be wary because a lot of the AJAX work [...]

JavaFX redux

Having spent a few weeks experimenting with JavaFX, and creating several examples, here is an assessment of whether JavaFX succeeds in it’s objective of being a graphics DSL. Bear in mind that I am evaluating it in terms of it’s ease in being a graphics DSL – if it makes my life easier, it succeeds. [...]

JavaFX TextAlignment Gotcha

Here is a minimal test case illustrating how exasperating the default JavaFX Text node can be, especially when aligning text.
You’d be surprised to note that both pieces of text below are aligned using TextAlignment.CENTER.

import javafx.scene.text.*;
import javafx.scene.layout.*;

VBox
{
translateY:10
content:
[
Text {
[...]

JavaFX Experiments – Order of Declaration Matters

Given the following piece of JavaFX Script

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import java.lang.Math.sqrt;

class C extends CustomNode
{
// Test #1: Commented out
//var node: Group = Group {};

protected override function create():Node
{
return node;
[...]

JavaFX Fidelity

JavaFX gets to start on a clean slate, without burdens of compatibility with browsers. However, how well does it paint itself?
How are – say – Rectangles defined?
Is the startX based on center lines? or is it from the origin?
What about borders? Are borders painted to the bottom right of the origin?
How [...]

JavaFX 1.0 considered

JavaFX 1.0 is finally out of the gate. There are probably many Java engineers and architects who are trying to figure out this technology and see how it could apply to their existing projects. Here is my assessment. Note this applies to JavaFX 1.0.
JavaFX 1.0 is not ready as a Flash replacement in public-facing projects
While [...]

Has the JVM design been holding back Java?

[Note: I've reposted this (with minor edits) as my original post got accidentally deleted. Thanks to Google cache]
Why is it? Why is it that Java applets -despite having the first mover advantage – achieved little traction. While Flash – a tool which targets graphic designers originally – continue to gain mindshare, and is now a [...]

Has the JVM design been holding back Java?

Update:Looks like the post has been linked from DZone. Tell me what you think? What kind of projects would you choose Java applets over Flash or AJAX?

After all these years, Java’s applet has not seen much adoption, while Flash continue to gain mindshare. Applets suffer from slow start up times, crashing browsers, heavy resource usage. [...]

Browsers will Rule Mobile Devices

Five years ago, when prototyping some apps for PDAs, I’d never consider HTML + javascript. This is because there are enough form factor issues as well as browser incompatibilities to keep one awake all night.
Things have changed.
WebKit seems to have gained ground in the mobile space, giving compatibility a much needed shot in the [...]

A concrete proposal for inlining JavaFX

Jan Erik calls me the “high IQ” type. Unfortunately, I think he means “impractical” and “living in an invory tower”.
The idea of a inlining JavaFX script is actually a smaller and incremental goal. It is practical and is achievable. It will allow people who don’t have the JavaFX SDK to experiment with the technology, within [...]

JavaFX and Disembodied Reality

Jan Erik opined insightfully about JavaFX’s prospect:
Java.net is disconnected with reality. For every guy who knows Swing/Java there are a 1000 guys who know HTML/DOM/CSS/Javascript. Silverlight is only marginally important because Microsoft controls 90 percent of the desktop marked and is the company behind C#.
JavaFX will ride the JRE in the same way AIR is [...]