Connection Pooling

About Support for Connection Pooling

The SAS Drivers for JDBC do not implement the JDBC pooling classes or interfaces. The recommended approach is to configure the application server to use pooled connections and to use the SAS driver.

Example: Configuring JBoss

This section provides a high-level and simple overview of the JBoss configuration needed to use the SAS drivers. It is assumed that you have JBoss installed, running, and operational. Note that this is just an example. JBoss is not recommended over other application servers.
Ensure that the JAR files for the SAS driver are located within the lib directory for the server:
$ pwd
.../jboss/jboss-4.2.0.GA/server/SASServer1
$ ls lib/sas.*.jar
lib/sas.core.jar
lib/sas.svc.connection.jar
Edit or create a data source XML file in the deploy directory:
$ cat deploy/iom-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>sas/jdbc/Iom</jndi-name>
    <connection-url>
      jdbc:sasiom://localhost:8591?librefs=
      HELP 'C:\Program Files\SAS\SASFoundation\9.2\core\sashelp'
    </connection-url>
    <driver-class>com.sas.rio.MVADriver</driver-class>
    <user-name>sasdemo</user-name>
    <password>{sas001}cGFzc3dvcmQ=</password>
    <min-pool-size>10</min-pool-size>
    <max-pool-size>50</max-pool-size>
  </local-tx-datasource>
</datasources>
Identify the DataSource jndi-name value as shown in the following example:
<%@page contentType="text/html"
  import="java.util.*,javax.naming.*,javax.sql.DataSource,
      java.sql.*,java.net.*,java.io.*"
  %>
  <html>
    <body>
      <p>Count of Subsidiaries by Region and Product</p>

<%
  DataSource ds = null;
  Connection con = null;
  InitialContext ic;
  String query = "SELECT REGION, PRODUCT, COUNT(SUBSIDIARY) " +
    "FROM HELP.shoes GROUP BY REGION, PRODUCT";
  String nbsp = "&nbsp;";

  try {
    ic = new InitialContext();
    ds = (DataSource) ic.lookup("java:/sas/jdbc/Iom");
    con = ds.getConnection();
    ResultSet rs = con.createStatement().executeQuery(query);
    ResultSetMetaData rsmd = rs.getMetaData();
    int colCount = rsmd.getColumnCount();
    out.println("<TABLE border='1'>");
    out.println("<TR>");
    for (int i = 1; i <= colCount; ++i) {
      out.println("<TH>" + rsmd.getColumnLabel(i) + "</TH>");
    }
    out.println("</TR>");

    String val = null;
    while (rs.next()) {
      out.print("<TR>");
      for (int i = 1; i <= colCount; ++i) {
        val = rs.getString(i);
        if (rs.wasNull()) {
          val = nbsp;
        }
        out.print("<TD>" + val + "</TD>");
      }
      out.println("</TR>");
    }
    out.println("</TABLE>");
    rs.close();
    con.close();
  } catch (Exception e) {
    e.printStackTrace();
  }
%>
   </body>
  </html>