Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package pt.webdetails.cda.connections.sql;
  
  
  import  org.dom4j.Element;
  import  org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.ConnectionProvider;
  import  org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.JndiConnectionProvider;
 import  org.pentaho.reporting.platform.plugin.connection.PentahoJndiDatasourceConnectionProvider;
Todo: Document me!

Date: 16.02.2010 Time: 12:54:14

Author(s):
Thomas Morgner.
 
 public class JndiConnection extends AbstractSqlConnection implements EvaluableConnection {
 
 
   public JndiConnection(final Element connection)
           throws InvalidConnectionException {
     super(connection);
   }
 
   public JndiConnection() {
   }
  
  
TODO:new API

Parameters:
jndi the connection name as defined in the datasources.xml file
 
   public JndiConnection(String idString jndi){
   	super(id);
   	this. = new SqlJndiConnectionInfo(jndi,null,null,null,null);
   }
   
   public JndiConnection(String idSqlJndiConnectionInfo info){
     super(id);
     this. = info;
   }
 
   public ConnectionProvider getInitializedConnectionProvider() throws InvalidConnectionException {
     final ConnectionProvider connectionProvider;
     if (CdaEngine.getInstance().isStandalone()) {
       final JndiConnectionProvider provider = new JndiConnectionProvider();
       provider.setConnectionPath(.getJndi());
       provider.setUsername(.getUser());
       provider.setPassword(.getPass());
       connectionProvider = provider;
     } else {
       final PentahoJndiDatasourceConnectionProvider provider = new PentahoJndiDatasourceConnectionProvider();
       provider.setJndiName(.getJndi());
       provider.setUsername(.getUser());
       provider.setPassword(.getPass());
       connectionProvider = provider;
     }
 
 
     try {
       final Connection connection = connectionProvider.createConnection(nullnull);
       connection.close();
     } catch (SQLException e) {
 
       throw new InvalidConnectionExceptiongetClass().getName() + ": Found SQLException: " + Util.getExceptionDescription(e), e);
     }
 
     return connectionProvider;
   }
 
   protected void initializeConnection(final Element connectionthrows InvalidConnectionException {
      = new SqlJndiConnectionInfo(connection);
   }
 
   public String getType() {
     return "sqlJndi";
   }
 
   public boolean equals(final Object o) {
     if (this == o) {
       return true;
     }
     if (o == null || getClass() != o.getClass()) {
       return false;
     }
 
     final JndiConnection that = (JndiConnectiono;
 
     if (!.equals(that.connectionInfo)) {
       return false;
    }
    return true;
  }
  public int hashCode() {
    return .hashCode();
  }
    ArrayList<PropertyDescriptorproperties = super.getProperties();
    return properties;
  }
  {
  }
  public String getUserField()
  {
    return .getUserField();
  }
    SqlJndiConnectionInfo info = new SqlJndiConnectionInfo( FormulaEvaluator.replaceFormula.getJndi()), 
                                                      .getUser(), 
                                                      .getPass(), 
                                                      .getUserField(), 
                                                      .getPasswordField());
    JndiConnection conn = new JndiConnection(getId(), info);
    return conn;
  }
	  return ;
  }
New to GrepCode? Check out our FAQ X