integrate javafx, hibernate and postgresql with the mvc pattern
DESCRIPTION
ntegrate JavaFX, Hibernate and PostgreSQL With the MVC PatternTRANSCRIPT
-
3/28/14 Integrate JavaFX, Hibernate and PostgreSQL with the MVC Pattern
www.devx.com/Java/Article/48193 1/3
Sign up for e-mail
newsletters from DevX
Enter email address
Jelastic Updates Java/PHP
PaaS With Git, SVN Auto-
Deploy, More
Getting Started w ith
Apache HBase
Approaches to Indexing
Multiple Logs File Types in
Solr and Setting up a Multi-
Node, Multi-Core Solr Cloud
Coding with JRebel: Java Forever Changed Download Now
TODAY'S HEADLINES | ARTICLE ARCHIVE | FORUMS | TIP BANK
Specialized Dev Zones
eBook Library
.NET
Java
C++
Web Dev
Architecture
Database
Security
Open Source
Enterprise
Mobile
Special Reports
10-Minute Solutions
DevXtra Blogs
Not having data governance can hurt your business. Download this eBook to learn how to take control now.
Integrate JavaFX, Hibernate and PostgreSQL with the MVC Pattern
This JavaFX tutorial demonstrates how to integrate JavaFX, Hibernate and PostgreSQL using the MVC pattern -- complete with a
sample application that features visual data navigation.
by Manoj Debnath
Jun 5, 2012
Page 1 of 2
JavaFX provides a rich set of UI controls, which simplify the development of visually immersivefront ends for database-driven applications. When combined with the PostgreSQL databaseand the Hibernate ORM tool, JavaFX can handle the presentation layer for large-scale, data-driven business applications (JavaFX PostgreSQL) as well as robust desktop applications(JavaFX Hibernate).
In this article, I demonstrate how to integrate JavaFX, Hibernate and PostgreSQL using theMVC pattern and present a sample CRUD application with a data-navigation feature.
What You Need
Java SDK + JavaFX 2
Eclipse IDE
Hibernate 4.x
PostgreSQL Database
PostgreSQL JDBC Driver
To follow the demo in this article, simply:
1. Install the Java SDK+JavaFX2 SDK2. Unpack the Eclipse IDE3. Install the PostgreSQL DB4. Unpack Hibernate5. Save the PostgreSQL JDBC driver
JavaFX / Hibernate / PostgreSQL Project Setup
From the File menu in Eclipse, choose Java Project. It is better to set up User Library of all JAR files required in the project. This is not anecessary procedure but it will come in quite handy for future reference. Let's make an individual library for the Hibernate JavaFX PostgreSQL driverand include it in our project, as shown in Figure 1.
Figure 1. Project Library: Make a library for the Hibernate JavaFX PostgreSQL driver.
PostgreSQL Table Structure
You don't need to worry about the structure of the sample table, Contact. It will be created automatically when the application runs. However, if youwant to create the table separately, you can but keep in mind the following comment for the code snippets in the rest of the article
cfg.setProperty("hibernate.connection.url","jdbc:postgresql://127.0.0.1:5432/testdb");
In this case, testdb is the table space. If you opt for creating your table through SQL or through pgAdmin III, either give the name of tablespace astestdb or change the appropriate portion of code in the HiberateUtil.java file.
cfg.setProperty("hibernate.hbm2ddl.auto", "update");
Also keep in mind the update value. You may also put create in place of update. This would recreate the table every time the application runs,deleting all stored information. So use create or update appropriately.
cfg.setProperty("hibernate.show_sql", "true");
Alternatively, you may set the above property as false.
The table created in PostgreSQL is as follows:
CREATE TABLE contacts
(
contactid integer NOT NULL,
-
3/28/14 Integrate JavaFX, Hibernate and PostgreSQL with the MVC Pattern
www.devx.com/Java/Article/48193 2/3
1 2 Next Page
Reply to this comment
Reply to this comment
email character varying(255),
firstname character varying(255),
lastname character varying(255),
phone character varying(255),
CONSTRAINT contacts_pkey PRIMARY KEY (contactid )
)
WITH ( OIDS=FALSE );
ALTER TABLE contacts OWNER TO postgres;
Next Page
2 Comments (click to add your comment)
By umair October 18 2013 00:52 AM PDT
Dear Manoj, Thankyou very much for this easy to understand and effective tutorial. With an ORM
architecture like you explained (seems session per click) if we develop a Java FX application with say
200+ clients, would it work or should we go for EJB approach. Thanks again for this self explanatory
example. Umair
By Sumudu June 29 2013 11:55 AM PDT
This is very very important one thank you very very much
Comment and Contribute
Your name/nickname
Your email
WebSite
Subject
(Maximum characters: 1200). You have 1200 characters left.
Submit Your Comment
Ketik teks
-
3/28/14 Integrate JavaFX, Hibernate and PostgreSQL with the MVC Pattern
www.devx.com/Java/Article/48193 3/3
Sitemap
Property of Quinstreet Enterprise.
Terms of Service | Licensing & Reprints | About Us | Privacy Policy | Advertise
Copyright 2014 QuinStreet Inc. All Rights Reserved.