Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.noorm.jdbc;
  
  import org.slf4j.Logger;
This class represents the configuration parameters available for NoORM data sources through configuration files noorm.xml or noorm.properties.

Author(s):
Ulf Pietruschka / ulf.pietruschka@etenso.com
 
 public class DataSourceConfiguration {
 
     private static final Logger log = LoggerFactory.getLogger(DataSourceConfiguration.class);
 
     private String databaseJNDIName;
     private String databasePlatform;
     private String databaseURL;
     private String databaseUsername;
     private String databasePassword;
     private int databaseBatchUpdateSize = 100;
     private boolean debugMode = false;
     private String debugJDWPPort = "4000";
     private String debugJDWPHost = "localhost";

    
Validates the given data source configuration. Since most configuration parameters may contain a variety of syntax options to specify its content, this method only checks, if either the JNDI name is provided or URL, username and password altogether. In case of a failed validation, DataAccessException(DataAccessException.Type.INITIALIZATION_FAILURE) is thrown.
 
     public void validate() {
 
         if ( == null || .isEmpty() ) {
             final String noJNDIConfig = "Either provide a JNDI data source configuration or provide all required" +
                     " parameters for explicit data source instantiation. ";
             if ( == null || .isEmpty()) {
                 final String errMsg = "JDBC data source platform not properly configured. ".concat(noJNDIConfig);
                 .error(errMsg);
                 throw new DataAccessException(..errMsg);
             }
             if ( == null || .isEmpty()) {
                 final String errMsg = "JDBC data source URL not properly configured. ".concat(noJNDIConfig);
                 .error(errMsg);
                 throw new DataAccessException(..errMsg);
             }
             if ( == null || .isEmpty()) {
                 final String errMsg = "JDBC data source username not properly configured. ".concat(noJNDIConfig);
                 .error(errMsg);
                 throw new DataAccessException(..errMsg);
             }
             if ( == null || .isEmpty()) {
                 final String errMsg = "JDBC data source password not properly configured. ".concat(noJNDIConfig);
                 .error(errMsg);
                 throw new DataAccessException(..errMsg);
             }
         }
     }
 
     public String getDatabaseJNDIName() {
         return ;
     }
 
     public void setDatabaseJNDIName(final String pDatabaseJNDIName) {
          = pDatabaseJNDIName;
     }
 
     public String getDatabaseUsername() {
         return ;
     }
 
     public void setDatabaseUsername(final String pDatabaseUsername) {
          = pDatabaseUsername;
     }
 
     public String getDatabasePassword() {
         return ;
     }
 
     public void setDatabasePassword(final String pDatabasePassword) {
          = pDatabasePassword;
     }
 
     public String getDatabasePlatform() {
         return ;
     }
 
     public void setDatabasePlatform(final String pDatabasePlatform) {
          = pDatabasePlatform;
     }
 
     public String getDatabaseURL() {
         return ;
     }
 
     public void setDatabaseURL(final String pDatabaseURL) {
          = pDatabaseURL;
     }
 
    public int getDatabaseBatchUpdateSize() {
        return ;
    }
    public void setDatabaseBatchUpdateSize(final int pDatabaseBatchUpdateSize) {
         = pDatabaseBatchUpdateSize;
    }
    public boolean isDebugMode() {
        return ;
    }
    public void setDebugMode(final boolean pDebugMode) {
         = pDebugMode;
    }
    public String getDebugJDWPPort() {
        return ;
    }
    public void setDebugJDWPPort(final String pDebugJDWPPort) {
         = pDebugJDWPPort;
    }
    public String getDebugJDWPHost() {
        return ;
    }
    public void setDebugJDWPHost(final String pDebugJDWPHost) {
         = pDebugJDWPHost;
    }
New to GrepCode? Check out our FAQ X