Highlighted

Help with DB connection

Avatar

Avatar

patrickpai

Avatar

patrickpai

patrickpai

22-05-2018

Hello again,

Looking at DB connections today, and was following this video for some guidance:

Creating a Database Connection - YouTube

Now, problem was getting the right bundle, couldn't find anything, so got a ticket open and i got some great help, i got MSSQL,oracle and MySQL drivers installed.

Next problem

As I'm following the video, I'm now at the point where i need to create a datasource. (video at about: 3.42min)

So i can start the Apache sling datasource, but at this point not sure what i'm exactly doing and i don't know what to enter in when we get to the JDBC connection URI and the username/password. i don't quite get this part.

What do i type in those 3 fields?? hope this makes a bit of sense, i do, like in the video use the JEE install on port 8080, so can anyone explain what is being done here and what i need to type into these fields? I'm trying ultimately to connect to an actual DB, but not sure if this time is now, or at a later step.

Thank you very much again,

Replies

Highlighted

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831
Arun_Patidar
MVP

22-05-2018

Hi,

you need to enter below details for 3 fields based on database server which you are trying to connect, for example for MySQL

1. Connection URI  --> jdbc:mysql://<server>:<port>/<database-name>

2. MySQL database login user (e.g. root)

3. MySQL database login password (e.g. root)

Hope this helps!

Highlighted

Avatar

Avatar

patrickpai

Avatar

patrickpai

patrickpai

23-05-2018

Super

If I want to connect to a MSSQL DB, how do I do it then?

Highlighted

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831
Arun_Patidar
MVP

23-05-2018

Hi,

You can do similar for MSSQL

jdbc:sqlserver://localhost;databaseName=AdventureWorks;integratedSecurity=true;

find more details below

Building the Connection URL | Microsoft Docs 

Highlighted

Avatar

Avatar

patrickpai

Avatar

patrickpai

patrickpai

23-05-2018

Perfect, thank you very much, I will try this now.

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

23-05-2018

Read this AEM Article to learn how to setup a Database connection using a DataSourcePool:

Scott's Digital Community: Injecting a DataSourcePool Service into an Adobe Experience Manager OSGi ...

This uses MySQL as an example - simply replace the config information to use your database, (as well as making sure you wrap the database driver file into an OSGi bundle)

Highlighted

Avatar

Avatar

patrickpai

Avatar

patrickpai

patrickpai

25-05-2018

Hi again,

Sorry for late reply, I did get to try this out and it looked like it was going to work, but I get error message, here are the 2 ways ive tried this connection string:

jdbc:sqlserver:// s-asd-sql2;databaseName=AEM;integratedSecurity=true;

jdbc:sqlserver://;servername=s-asd-sql2;databaseName=AEM;

Both give me the same error message when I go back to AEM forms and create a DB connection from this Datasource.

It creates it and then I go into “Edit mode” and I see the datasource name on the left pane, but with a red exclamation point, which reads ”error in fetching datasource”.

Any idea what I should be looking for to fix this.

Thanks again

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

25-05-2018

In your use  case - do you have a custom OSGi bundle where you have SQL logic?