Open jmstephensgit opened 2 years ago
To make the example as clear as possible, change it to:
@Resource(name = "java:comp/env/jdbc/mydbresourceRef", lookup="jdbc/mydbresource")
DataSource mydbresource;
and
<resource-ref name="java:comp/env/jdbc/mydbresourceRef">
<authentication-alias name="auth1"/>
</resource-ref>
By avoiding using the same name for 2 different things, that will make it more clear to the reader which each pertains to.
In the documentation, https://www.ibm.com/docs/en/was-liberty/base?topic=applications-configuring-authentication-aliases-liberty#twlp_sec_jca__adeappbind
@Resource (lookup="jdbc/mydbresource") DataSource mydbresource;
should be changed to
Add a Resource annotation to your application to enable the application server to inject the resource reference or add the resource to your application deployment descriptor.
@Resource (name="jdbc/mydbresource") DataSource mydbresource;
In addition, the first example should be to the last example. Add a code example using the resource created.
Connection c = mydbresource.getConnection();