First of all, I recommend that you use a DataSource for your application instead of a raw JDBC driver. By using a DataSource (which are container managed when configured on an application server) you will benefit from many inherent optimizations done by the application server, such as connection pooling and transaction support.
Note that a DataSource is not specific to WAS Liberty, in any app server you will get higher performance at a lower development cost by using a container managed DataSource instead of a raw JDBC drivers.
To configure a DataSource:
Configure the DataSource and JDBC library in the server.xml:
<!-- Enable JDBC and JNDI features (at least) -->
<featureManager>
<feature>jdbc-4.1</feature>
<feature>jndi-1.0</feature>
</featureManager>
<dataSource id="MyDataSource" jndiName="jdbc/MyDataSource">
<jdbcDriver libraryRef="MSJDBCLib"/>
<properties.microsoft.sqlserver databaseName="SAMPLEDB" serverName="localhost" portNumber="1433"/>
</dataSource>
<library id="MSJDBCLib">
<fileset dir="C:/path/to/sqljdbc4.jar"/>
<!-- To have authentication support, add the dll to the library -->
<fileset dir="C:/path/to/sqljdbc_auth.dll"/>
</library>
See IBM doc: Configuring database connectivity in Liberty
The key to answering your question is to add the <fileset>
element pointing to the auth dll file in your <library>
element like this:
<!-- To have authentication support, add the dll to the library -->
<fileset dir="C:/path/to/sqljdbc_auth.dll"/>
To use a DataSource:
Before, you probably did something like this:
String connectionURL = "jdbc:sqlserver://localhost:1433;DatabaseName=YourDBName;user=UserName;Password=YourPassword";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection(connectionUrl);
With DataSources, you can inject them or look them up using JNDI:
Inject:
@Resource(lookup = "jdbc/MyDataSource")
DataSource myDataSource;
...
Connection con = myDataSource.getConnection();
JNDI Lookup:
DataSource myDataSource = new InitialContext().lookup("jdbc/MyDataSource");
Connection conn = myDataSource.getConnection();