I was dabbling with connecting to JavaDB database using JavaFX back in September, just did not get around to putting it on the blog. I had previously written a simple Celsius Converter application using JavaFX.  Here, I am limiting to a a short  piece of code demonstrating the database connection part in the JavaFX application. Ofcourse I am using NetBeans. While I was at it, I decided to also try it using  MySQL.  This also demonstrates how easy it is to switch between databases (ofcourse you need to have the same schema available on both databases used) in NetBeans.  Note that in order to switch to MySQL besides changing the database parameters in the code, all I had to do was add the mysql-connector-java-5.0.7-bin.jar file under the Library node of the Project, instead of derby.jar.  Below are the screen shots of the application as well as the source code.

Using JavaDB



Using MySQL

Using MySQL 

TableSample Output

 

Source Code for TableSample application:

Main.fx

DatabaseAccess.fx 


Comments:

Thank you - this rocks!
I'm eagerly awiting more examples like this on how to build real world applications using JavaFx.

Posted by elwis on January 23, 2008 at 03:39 AM PST #

great! I'm expecting more examples,especially RIA applications

Posted by sxdai on February 13, 2008 at 09:17 AM PST #

great! I'm expecting more examples,especially RIA applications
-------------------------------------

look to

http://molgav.nn.ru/index.php?option=com_content&view=article&id=229%3Apractical-guide-to-javafx&Itemid=56

Posted by surikov on February 14, 2008 at 12:50 AM PST #

That was exactly what i was looking for...Thanks !

Posted by SVASEARCH on August 01, 2008 at 05:35 AM PDT #

I have not been able to get these examples to work with the preview release of JavaFX. Are there syntax changes required now to make these examples work?

Posted by Jason Jones on October 01, 2008 at 02:24 AM PDT #

As per
http://javafx.netbeans.org/
...The JavaFX Script plugin for Netbeans IDE 6.1 supports the JavaFX Script language that is based on the OpenJFX compiler... (The previous versions were based on interpreter-based version of the language).

There are several samples available from the following sites:
http://wiki.netbeans.org/FaqFXProjectDiff
http://java.sun.com/javafx/reference/
http://java.sun.com/javafx/reference/samples/
http://jfx.wikia.com/wiki/Code_Examples
http://jfx.wikia.com/wiki/Database
Can you check them out and see if they help?

You may also want to raise your question on the javafx forums at:
http://forums.sun.com/category.jspa?categoryID=132

Posted by Karthikeyan Rajeswaran on October 06, 2008 at 01:05 PM PDT #

Good Example, near the real word.

Posted by jamc on November 18, 2008 at 01:43 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2010 by radhika