JDBC Connection DataSource in a Servlet | Community
Skip to main content
crich2784
Level 6
May 23, 2021 9:29 PM UTC
Solved

JDBC Connection DataSource in a Servlet

 

I have tried dependency injection but, it cannot find my "Apache Sling Connection Pooled DataSource"

@3214626
private DataSourcePool dsp;

 

DataSource ds = (DataSource) dsp.getDataSource("MYDB");

 

I am using SlingSafeMethodsServlet.

 

Any help would be appreciated.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
crich2784
crich2784Accepted solution
Level 6
May 23, 2021 10:34 PM UTC

Figured it out.

 

@3214626(target = "(&(objectclass=javax.sql.DataSource)(datasource.name=MYDB))")
private DataSource ds;

1 reply

crich2784
crich2784AuthorAccepted solution
Level 6
May 23, 2021 10:34 PM UTC

Figured it out.

 

@3214626(target = "(&(objectclass=javax.sql.DataSource)(datasource.name=MYDB))")
private DataSource ds;

Translate