Class DataSourceUtil


  • public class DataSourceUtil
    extends java.lang.Object

    A simple DataSource utility for the standard DriverManager class.

    TODO: need to cache DataSource

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String ESCAPE  
      private static java.lang.String TOKEN  
    • Constructor Summary

      Constructors 
      Constructor Description
      DataSourceUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static javax.sql.DataSource getDataSource​(java.lang.Object rawDataSource, javax.servlet.jsp.PageContext pc)
      If dataSource is a String first do JNDI lookup.
      private static javax.sql.DataSource getDataSource​(java.lang.String params)
      Parse JDBC parameters and setup dataSource appropriately
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DataSourceUtil

        public DataSourceUtil()
    • Method Detail

      • getDataSource

        static javax.sql.DataSource getDataSource​(java.lang.Object rawDataSource,
                                                  javax.servlet.jsp.PageContext pc)
                                           throws javax.servlet.jsp.JspException
        If dataSource is a String first do JNDI lookup. If lookup fails parse String like it was a set of JDBC parameters Otherwise check to see if dataSource is a DataSource object and use as is
        Throws:
        javax.servlet.jsp.JspException
      • getDataSource

        private static javax.sql.DataSource getDataSource​(java.lang.String params)
                                                   throws javax.servlet.jsp.JspException
        Parse JDBC parameters and setup dataSource appropriately
        Throws:
        javax.servlet.jsp.JspException