Eclipse/Hibernate – Installation – Day/01

 

Outline

  1. Download & Install Eclipse
  2. JDBC Driver
    • Microsoft JDBC Driver
      • Download Microsoft JDBC Driver
  3. Configure Database
    • Microsoft SQL Server
      • Provision Database
        • WideWorldImporters ( Sample Database )
          • Restore Database
      • Provision Principal
        • Create SQL Server Principal
        • Grant Principal access to database
        • Grant principal access to database objects
  4. Configure Eclipse
    • Install Components
      • JBoss Tools
        • Hibernate

Tasks

Download & Install Eclipse

Please peruse this post per installing Eclipse :-

Eclipse IDE – Installation On MS Windows
Link

JDBC Drivers

Our database back-end is Microsoft SQL Server and so we will reach for Microsoft SQL Server JDBC Drivers.

Microsoft

SQL Server

JDBC Driver
Links
  1. Microsoft JDBC Driver for SQL Server
    Link
  2. Download Microsoft JDBC Driver for SQL Server
    Link
Available

Here are all the drivers available as of 2019-May-6th :-drivers.microsoft.jdbc.20190506.1231PM

We are on 7.0.

And, we will cover that in this post!

Database

Again, our database back-end is Microsoft SQL Server.  There are a few sample databases on that platform; the latest official is WorldWideImporters.

Microsoft

SQL Server

Worldwide Importers
Links
  1. SQL Samples
    Link
  2. Wide World Importers
    • Wide World Importers sample database v1.0
      Link
Brochure

Brochure

microsoft.sample.20190506.1246PM

Choice

We can go with traditional database backup files ( bak ).

Or with bacpac.

We chose :-

SQL Server 2016 SP1 (or later) Any Edition aside from LocalDB; SQL Server 2016 RTM (or later) Evaluation/Developer/Enterprise Edition
WideWorldImporters-Full.bak

Restore database

Launched SQL Server Management Studio and restored the backup file


USE [master]
go

exec master..xp_create_subdir N'C:\Microsoft\SQLServer\Datafiles\WideWorldImporters\'
go

exec master..xp_create_subdir N'C:\Microsoft\SQLServer\Logfiles\WideWorldImporters\'
go

RESTORE DATABASE [WideWorldImporters]
FROM  DISK = N'C:\downloads\Microsoft\SQLServer\Sample\WideWorldImporters\WideWorldImporters-Full.bak'
WITH
       FILE = 1
    ,  MOVE N'WWI_Primary' TO N'C:\Microsoft\SQLServer\Datafiles\WideWorldImporters\WideWorldImporters.mdf'
    ,  MOVE N'WWI_UserData' TO N'C:\Microsoft\SQLServer\Datafiles\WideWorldImporters\WideWorldImporters_UserData.ndf'
    ,  MOVE N'WWI_Log' TO N'C:\Microsoft\SQLServer\Logfiles\WideWorldImporters\WideWorldImporters.ldf'
    ,  MOVE N'WWI_InMemory_Data_1' TO N'C:\Microsoft\SQLServer\Datafiles\WideWorldImporters\WideWorldImporters_InMemory_Data_1'
    ,  NOUNLOAD
    ,  STATS = 5
    ,  REPLACE

GO
Create Database Account

Let us create SQL Server Account


use [WideWorldImporters]
go

/*
    SQL Server Principal - helloDB
*/
if suser_id('helloDB') is null
begin

    create login [helloDB]
    with password = 'Nu3Hu5RuSt'
       , DEFAULT_DATABASE = [WideWorldImporters]
       , CHECK_EXPIRATION = OFF
       , CHECK_POLICY = OFF

end
go

/*
    SQL Server Principal - helloDB
*/
if user_id('helloDB') is null
begin

    create user [helloDB]
    from login [helloDB];

end
go

grant select, insert, update, delete on schema::[Application] to [helloDB]
go

grant select, insert, update, delete on schema::[Purchasing] to [helloDB]
go

grant select, insert, update, delete on schema::[Sales] to [helloDB]
go

grant select, insert, update, delete on schema::[Warehouse] to [helloDB]
go

jboss.org

Available Software

In the Work With entry box, please enter :-

http://download.jboss.org/jbosstools/photon/development/updates

Once entered please click the “Add…” button

install.AvailableSoftware.02.WorkWith.20190505.0225PM.PNG

Add Repository

Please give a Name for the Repository we are adding.

In our case we chose jboss.

install.AvailableSoftware.03.WorkWith.20190505.0225PM.PNG

 

Check the items that you wish to install

Using Web Services, jboss.org is reached.

Available Items are returned and displayed.

install.AvailableSoftware.05.AddRepository.20190505.0228PM.PNG

Item – jBoss Data Services Development

We selected the following items :-

  1. JBoss Data Services Development
    • Hibernate Tools

install.AvailableSoftware.06.AddRepository.20190505.0229PM.PNG

Item – jBoss Data Services Development – Install Details

Please review the selected items :-

  1. JBoss Data Services Development
    • Hibernate Tools

install.AvailableSoftware.07.AddRepository.20190505.0230PM.PNG

 

Item – Review Licenses

Please review License Agreement

  1. License text(for Hibernate Tools 5.4.4.v20190328-1505)

 

Item – Review Licenses

Please review License Agreement

  1. License text(for Hibernate Tools 5.4.4.v20190328-1505)

Item – Installing Software

 

Item – Security Warning

Security Warning – The authenticity or validity of the software cannot be established

Even Hibernate.org is shipping software without SSL Certificates?

 

It is good, please click “Install anyway”.

Restart

Please restart Eclipse ID to effect the changes.

Restarted

Upon restart, we are asked to opt in for anonymous usage statistics.

Summary

Enough shenanigans for Day 01.

 

 

Eclipse – Data Source Explorer – SQL Server – Configuration ( Day 01 )

Background

Ran into a blocking issue while playing around with Eclipse.

The issue surfaced while trying to configure Hibernate to connect to SQL Server.

 

Data Source Explorer

I tried using the Hibernate Data Tools to connect to my back-end database; SQL Server in this case.

Finally gave up and wanted to see if I can reproduce the error using other data tools.

Process

Outline

  1. Perspective
    • Change to Data Development Perspective
  2. Driver Templates
    • Does Not Work
      • Microsoft SQL Server 2016 JDBC Driver
        • Specify a Driver Template and Definition Name
          • Driver Name :- Microsoft SQL Server 2016 JDBC Driver
          • Driver Type :- Microsoft SQL Server 2016 JDBC Driver
        • Tab :- JAR List
          • Removed
            • Removed sqljdbc.jar
          • Added
            • Added mssql-jdbc-7.0.0.jre10.jar
        • Tab :- Properties
          • Filled out properties tab
        • Tested Connection
          • Errors Out
            • java.lang.UnsupportedClassVersionError: com/microsoft/sqlserver/jdbc/SQLServerDriver has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    • Works
      • Microsoft SQL Server 2008 JDBC Driver
        • Specify a Driver Template and Definition Name
          • Driver Name :- Microsoft SQL Server 2008 JDBC Driver
          • Driver Type :- Microsoft SQL Server 2008 JDBC Driver
        • Tab :- JAR List
          • Removed
            • Removed sqljdbc.jar
          • Added
            • Added mssql-jdbc-7.0.0.jre8.jar
        • Tab :- Properties
          • Filled out properties tab
        • Tested Connection
          • Ping Successful
  3. Data Explorer
    • Review Data Explorer

Perspective

Database Development

Image

perspective.OpenPerspective.01.20190505.1033PM.PNG

Connection Profile

Driver Templates

Driver Templates – v 2016

Image
Image – Connection Profile

connectionProfile.01.20190505.1052PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – Name/Type

DriverTemplateAndDriverName.Tab.NameAndType.01.20190505.1059PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – JAR List – 01

DriverTemplateAndDriverName.Tab.JARList.01.20190505.1100PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – JAR List – 02

Removed sqljdbc.jar

DriverTemplateAndDriverName.Tab.JARList.02.20190505.1101PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – JAR List – 04

Added mssql-jdbc-7.0.0.jre10.jar

DriverTemplateAndDriverName.Tab.JARList.03.20190505.1121PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – Properties – 01

Review Properties Tab

DriverTemplateAndDriverName.Tab.Properties.01.20190505.1104PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – Properties – 02

Completed Properties Tab

DriverTemplateAndDriverName.Tab.Properties.02.20190505.1105PM.PNG

Image – Specify a Driver and Connection Details

Review Driver and Connection Details ….

connectionProfile.jre10.01.SpecifyADriverAndConnectionDetails.02.20190505.1118PM.PNG

Image – Ping failed!

Ping failed.

pingFailed.20190505.1120PM.PNG

Ping failed.

java.lang.UnsupportedClassVersionError: com/microsoft/sqlserver/jdbc/SQLServerDriver has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at java.net.URLClassLoader.defineClass(Unknown Source)
	at java.net.URLClassLoader.access$100(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.net.FactoryURLClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:327)
	at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
	at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
	at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:96)
	at org.eclipse.datatools.enablement.msft.internal.sqlserver.connection.JDBCSQLServerConnectionFactory.createConnection(JDBCSQLServerConnectionFactory.java:27)
	at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
	at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
	at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
	at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Driver Templates – v 2008

Image
Image – Connection Profile

connectionProfile.01.20190505.1052PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – Name/Type

Please choose “Microsoft SQL Server 2008 JDBC Driver

ConnectionProfile.SpecifyADriverAndDefinitionName.Tab.NameAndType.01.20190505.1112PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – JAR List – 01

DriverTemplateAndDriverName.Tab.JARList.01.20190505.1100PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – JAR List – 02

Removed sqljdbc.jar

DriverTemplateAndDriverName.Tab.JARList.02.20190505.1101PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – JAR List – 03

Using the OS “Select the file” functionality reach for mssql-jdbc-7.0.0.0.jre8.jarpingSucceedded.20190505.1124PM.PNG.

DriverTemplateAndDriverName.Tab.JARList.SelectTheFile.03.20190505.1122PM.PNG

 

Image – Specify a Driver Template and Definition Name – Tab – JAR List – 04

Added mssql-jdbc-7.0.0.jre8.jar

DriverTemplateAndDriverName.Tab.JARList.04.20190505.1123PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – Properties – 01

Review Properties Tab

DriverTemplateAndDriverName.Tab.Properties.01.20190505.1104PM.PNG

Image – Specify a Driver Template and Definition Name – Tab – Properties – 02

Completed Properties Tab

DriverTemplateAndDriverName.Tab.Properties.02.20190505.1105PM.PNG

Image – Specify a Driver and Connection Details

Review Driver and Connection Details ….

connectionProfile.jre10.01.SpecifyADriverAndConnectionDetails.02.20190505.1118PM.PNG

Image – Test Connection

Tested Connection

pingSucceedded.20190505.1124PM.PNG

 

Issues

Java Runtime Compatibility ( JRE )

Hibernate

Compatibility Matrix

Hibernate Compatibility Matrix is available here.

Image

compatibilityMatrix.01.20190506.1250AM

Explanation
  1. Hibernate ORM
    • v6.0
      • Java 8 or 11
    • v5.4
      • Java 8 or 11

Microsoft JDBC Driver

mssql-jdbc-7.0.0.jre10.jar

Naming Convention

The name, mssql-jdbc-7.0.0.jre10.jar, is telling :-

  1. mssql
  2. jdbc
  3. 7.0.0
    • Version of MSSQL/JDBC is 7
  4. jre10
    • Requires Java Runtime 10
  5. jar
    • Jar File
Implication
  1. mssql-jdbc-7.0.0.jre10.jar requires Java JRE 10
    • Hibernate does not support JRE 10
      • It appears we have an incompatibility

mssql-jdbc-7.0.0.jre8.jar

Naming Convention

The name, mssql-jdbc-7.0.0.jre8.jar, is telling :-

  1. mssql
  2. jdbc
  3. 7.0.0
    • Version of MSSQL/JDBC is 7
  4. jre8
    • Requires Java Runtime 8
  5. jar
    • Jar File
Implication
  1. mssql-jdbc-7.0.0.jre8.jar requires Java JRE 8
    • Hibernate does support JRE 8
      • It appears we are good with compatibility

 

 

Data Explorer

Images

Image – Data Explorer – 01

DataSourceExplorer.02.20190505.1126PM.PNG

Dedicate

Always a dedicated piece.

This time it is Kenji Hasunuma.

  1. Kenji Hasunuma
    • How to connect to SQL Server 2016 by Eclipse DTP (en)
      Link