There are a lot of advantages by having a database connection directly from your IDE while developing an application. You can reuse that connection and leverage some utilities like a JPA Entities from Tables wizard to generate your Java objects using your preferred ORM framework or even test some queries before getting those written to your application. Some tools may even generate detailed diagrams, useful for documentation.
I’m going to illustrate a step-by-step guide on how to setup such connection on the most popular Java IDEs
- Spring Tool Suite – STS (Eclipse)
How to setup GemFire XD connection from IntelliJ 12
- In IntelliJ, click on View > Tools Windows > Database
- Under the Database tab right-click and select New > Data source
- In the Data Source properties set your data source name (GFXD Connection for example)
- In the JDBC Driver Source, click on the “…” browse to your GemFireXD installation directory and under /lib select sqlfireclient.jar
- Make sure JDBC driver class is set to com.vmware.sqlfire.jdbc.ClientDriver
- Set Database URL to jdbc:sqlfire://<HOSTNAME>:1527 and user and password to the same value: “app”
- Before testing, let’s set the SQL Dialect to Derby, as GemFireXD is based on Derby – To do that, go to the Console tab and select from the Derby on the dialect list.
- Back on the Database tab, click Test Connection and if you get a success message click Ok.
- Now still in the database tab right-click the SYS schema – Under Diagrams select Show Visualization – This will generate a graphical view of internal tables of GemFire XD, very useful for troubleshooting or to a better understanding of internal tables.
- To complete this tutorial, let’s open a simple SQL command prompt – Right-click the connection and select Console
- In the console you have auto-completion for most SQL commands and table names. Run a “select * from sys.members;” in order to check the current running members of the distributed system.
Now let’s repeat the steps above on STS and Netbeans.
How to setup GemFire XD connection from Spring Tool Suite (STS)
- In STS (Eclipse) click on File > New > Other
- Expand Connection Profiles in the wizard window and select Connection Profile and click Next
- In the Connection Profile types, select Derby and give your connection a name (GFXD Connection for example) – Click Next
- In the Drivers selection, click on New Driver Definition
- Select Other Driver from the list – You can use version 10.2 – Fill the driver name with “GemFireXD Driver”
- Click on JAR List tab, then Add JAR/Zip… and look for sqlfireclient.jar under /lib directory of GemFireXD installation
- Move to the Properties tab and set the properties as the following:
- Click Ok and make sure you have GemFireXD Driver in the drivers combo box.
- Click on Test Connection and if you get a success message, you’re good to go.
- To start using your connection, go to Window > Open Perspective > Other and select Database Development then click Ok
- Then under Data Source Explorer right-click the GFXD Connection and click Open SQL Scrapbook
- Now you can easily manage your tables and perform SQLF queries directly from STS.
How to setup GemFire XD connection from NetBeans 7.x
- On NetBeans, go to Services tab, right-click Databases and select New Connection
- In the New Connection Wizard window, set the Driver combo box to New Driver, which will bring up a new window
- Set up the Driver File to sqlfireclient.jar located under /lib of GemFire XD installation
- In the Driver class field click on the Find button so the IDE will look for Driver classes on the jar file.
- Set the Name as “GemFire XD Driver” and click Ok.
- Back at New Connection wizard, GemFire XD Driver will be already selected, so just click Next
- Now just fill username/password (app/app) and set the URL to jdbc:sqlfire://<HOSTNAME>:1527
- Click Next – Select your default schema and Next again
- Give your connection a meaningful name – “GemFireXD Connection” for example
- Now you are ready to manage and query your tables through NetBeans
Note 1: If you authentication enabled (auth-provider property) use the user and password specified at those settings, otherwise the default user/password are app/app.
Note 2: The hostname used in the connection can be a locator or an specific server of your distributed system.
You can read more about GemFire XD at:
- Download - http://www.gopivotal.com/products/pivotal-hd#download-steps
- Documentation - http://gemfirexd-05.run.pivotal.io/topic/com.pivotal.gemfirexd.0.5/getting_started/3rd_party_connections.html
- Pivotal HD - http://www.gopivotal.com/products/pivotal-hd
- GemFire - http://www.gopivotal.com/products/pivotal-gemfire