Database access from JavaFX Script
By octav on Jan 18, 2009
Given that there is a wealth of JDBC code out there, I suspect that many developers may try to leverage their investment as they build new rich internet applications with JavaFX. I'll be using NetBeans 6.5 to demonstrate a simple example.
We'll use a simple JavaFX script project, which generates hello world code. Use the libraries node in the project view to add the "Java DB Driver".
As you can see, I am calling TalkToJavaDB.getRecord() which returns a java.lang.String, which in turn I assign to the Text object in my JavaFX script. I am using the Java String object to store an index of the java.sql.ResultSet I get from connecting to a JavaDB (derby) that ships with either Java 6 or GlassFish (v2 in my case).
This example is very trivial and may improve it in time to iterate over the ResultSet and present the data in a more visually apealing way (after all JavaFX enables developers to build great user interfaces, in many cases in half the time and with a lot less code)