Help with DB connection

Avatar

Avatar
Validate 1
Level 2
patrickpai
Level 2

Likes

3 likes

Total Posts

44 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
Level 2
patrickpai
Level 2

Likes

3 likes

Total Posts

44 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
patrickpai
Level 2

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

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,322 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,322 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
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!

Avatar

Avatar
Validate 1
Level 2
patrickpai
Level 2

Likes

3 likes

Total Posts

44 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
Level 2
patrickpai
Level 2

Likes

3 likes

Total Posts

44 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
patrickpai
Level 2

23-05-2018

Super

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

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,322 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,444 likes

Total Posts

3,322 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
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 

Avatar

Avatar
Validate 1
Level 2
patrickpai
Level 2

Likes

3 likes

Total Posts

44 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
Level 2
patrickpai
Level 2

Likes

3 likes

Total Posts

44 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
patrickpai
Level 2

23-05-2018

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

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

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)

Avatar

Avatar
Validate 1
Level 2
patrickpai
Level 2

Likes

3 likes

Total Posts

44 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
Level 2
patrickpai
Level 2

Likes

3 likes

Total Posts

44 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
patrickpai
Level 2

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

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

25-05-2018

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