Package org.uengine.util.dao

Source Code of org.uengine.util.dao.DataSourceConnectionFactory

/*
* Created on 2004. 12. 15.
*/
package org.uengine.util.dao;

import javax.sql.*;
import javax.transaction.UserTransaction;

import java.io.Serializable;
import java.sql.*;
import javax.naming.*;

import org.uengine.kernel.UEngineException;

/**
* @author Jinyoung Jang
*/
public class DataSourceConnectionFactory implements ConnectionFactory {
  private static final long serialVersionUID = org.uengine.kernel.GlobalContext.SERIALIZATION_UID;
  public Connection getConnection() throws Exception{
    InitialContext ctx = null;
    ctx = new InitialContext();
   
    if(getDataSourceJndiName()==null)
      throw (new UEngineException("Data Source JNDI name is null. Check whether the JNDI name is null."));
   
    DataSource ds = (javax.sql.DataSource) ctx.lookup(getDataSourceJndiName());
    Connection conn = ds.getConnection();
   
    return conn;
  }
 
  String dataSourceJndiName;
 
  public String getDataSourceJndiName() {
    return dataSourceJndiName;
  }

  public void setDataSourceJndiName(String string) {
    dataSourceJndiName = string;
  }

}
TOP

Related Classes of org.uengine.util.dao.DataSourceConnectionFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.