Database Connections

Introduction

JPA Structure panel is responsible for everything related to DB configurations. To create a new DB connection, click on the “Plus” button and choose “DB Connection”. To use Reverse Engineering and Database Versioning features, the first thing you will need to do is create a database connection.

For now, JPA Buddy supports following databases:

You can fill the required settings for the connection manually, but if your project contains data source settings in the application.properties file, JPA Buddy can get them and paste into corresponding fields automatically. Click on the “Detect Connections” button in the JPA Structure panel and the window will appear with filled fields.

As the IntelliJ IDEA Ultimate provides a large number of options for data sources configurations, there is no needs to create other connections to make JPA Buddy works. You can learn more about it on the corresponding JetBrains documentation page.

For the IntelliJ IDEA Community edition, JPA Buddy offers a similar mechanism.

Non-Default Schema Connection

Some of the RDBMSs that JPA Buddy supports provide the possibility to create non-default schemas, but not all of them work well with JDBC. That’s why you can face with some known issues during diff generations, or reverse engineering. For now, these issues can only be solved with some workaround. Below are examples of connecting to non-default schemas for all databases supported by JPA Buddy.

We show two screenshots for all the examples below: the first from the IntelliJ IDEA Community Edition, the second from the IntelliJ IDEA Ultimate Edition.

PostgreSQL

The default PostgreSQL schema is “public”. For other schemes you need to specify desired schema name in the Connection params field via “currentSchema” parameter:

For IntelliJ IDEA Ultimate, JPA Buddy provides connection creating for the required schema without any actions from you. For example, use a connection with the default schema (public) and try to create an entity from another schema. JPA Buddy will create and configure another DB connection with the parameters as described above.

Microsoft SQL Server

The default Microsoft SQL Server schema is “dbo”. To connect to the non-default scheme in Microsoft SQL Server, you should follow the steps described below:

  1. Create a login:
create login JohnDoe with password='saPassword1'
  1. Create a user with default schema from which you want to create an entity:
create user JohnDoe for login JohnDoe with default_schema = my_schema 
  1. Give it owner rights:
exec sp_addrolemember 'db_owner', 'JohnDoe' 
  1. Create a new connection with the newly created user’s credentials and add schema name in the database URL field

For JDBC the connection setup will look like this:

And for JTDS like this:

Oracle

In Oracle, schema, user and database are the same thing. Hence To connect to the non-default scheme you need to specify schema name in the user field.

For the connection via SID setup will look like this:

And for the connection via service name like this:

Reverse engineering does not work for system tables located in the "SYS” schema.

MySQL & MariaDB

To connect to the non-default scheme you need to specify schema name in the Database URL field:

Database Drivers

Since IntelliJ IDEA CE doesn't allow configuring database drives, JPA Buddy is to the rescue! Open Tools -> JPA Buddy -> Database Drivers window. Here you can configure drivers for each supported RDBMS by selecting one of the proposed driver versions and adding additional files from your local machine.