Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

JDBC Connection DataSource in a Servlet

Avatar

Level 7

 

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

@reference
private DataSourcePool dsp;

 

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

 

I am using SlingSafeMethodsServlet.

 

Any help would be appreciated.

 

1 Accepted Solution

Avatar

Correct answer by
Level 7

Figured it out.

 

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

View solution in original post

1 Reply

Avatar

Correct answer by
Level 7

Figured it out.

 

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