Portlet access to RDBMS
|Status:||Closed||Start date:||Apr 27, 2016|
|Assignee:||Massimiliano Assante||% Done:|
We are developing a user portlet and we are using Hibernate for data management. The jdbc connection is in a config xml file. Right now we are invoking a local postgres.
Upon deployment the portlet should invoke a database on the server. How do we request for the database connection info?
Mind that we are using gcube portlet 4.0.0-SNAPSHOT and we are not using GWT.
#1 Updated by Massimiliano Assante over 3 years ago
- Assignee changed from _InfraScience Systems Engineer to Panagiota Koltsida
upon deployment the portlet should invoke a database on the infrastructure, the db coordinates and credentials will be registered into a service endpoint to type database in the infrastructure information system. Please refer to our greek colleagues @NKUA to understand how to register a new service endpoint in the infrastructure.
I'm reassigning the ticket to @email@example.com
#7 Updated by Lucio Lelii over 3 years ago
- Assignee changed from Lucio Lelii to Massimiliano Assante
First of all you have to add a ServiceEndpoint with all the information related to your database in the IS (@firstname.lastname@example.org can you provide the wiki link for ServiceEnpoint creation) and then you have to use the ic-client (https://wiki.gcube-system.org/gcube/Ic-client) to discover this resource and retrieve the information you need for the connection.
#8 Updated by Massimiliano Assante over 3 years ago
I'll try to explain better:
Hibernate is supported, but the credentials about jdbc connection that you read in a config xml file, must be changed so that you will read them from the infrastructure. In order to do so we will create an infrastructure resource of type "Service Endpoint" that will contain all the necessary information about jdbc connection.
I'm reporting below a service endpoint example used from some portlet to access a database (SardaraDB) so that you can better understand what I am talking about.
<Resource version="0.4.x"> <ID>25005aaa-3bb6-4003-961d-2f9c3ca842be</ID> <Type>RuntimeResource</Type> <Scopes> <Scope>/d4science.research-infrastructures.eu</Scope> </Scopes> <Profile> <Category>Database</Category> <Name>SardaraDB</Name> <Description>PostGIS DB</Description> <Platform> <Name>Postgres</Name> <Version>9</Version> <MinorVersion>2</MinorVersion> <RevisionVersion>0</RevisionVersion> <BuildVersion>0</BuildVersion> </Platform> <RunTime> <HostedOn>db-tuna.d4science.org</HostedOn> <GHN UniqueID="" /> <Status>READY</Status> </RunTime> <AccessPoint> <Description>SardaraDB</Description> <Interface> <Endpoint EntryName="sardaradb">db-tuna.d4science.org</Endpoint> </Interface> <AccessData> <Username>********</Username> <Password>************</Password> </AccessData> </AccessPoint> </Profile>
Once you provide us with the necessary information about jdbc connection (host, db name and credentials) we will create one resource for your portlet. CNR can do this.
Now, in order to retrieve the jdbc connection from the infrastructure you should use a specific library called ic-client, please see this: https://wiki.gcube-system.org/gcube/Ic-client#Conditions_and_Result_Expressions
What you will also need are the development encryption keys to decrypt the db credentials, we can point you to them.