connectionfactory.java

来自「Speedframework--基于类型元数据的羽量级ORM.完全基于Java类」· Java 代码 · 共 65 行

JAVA
65
字号
package org.speedframework.conneciton;

import java.sql.Connection;
import org.speedframework.configure.ConnConfigure;
import java.sql.SQLException;
import org.speedframework.exception.SpeedException;

/**
 * <p>Title: SpeedFrameworkWork持久层框架</p>
 *
 * <p>Description:连接类 </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: SpeedFrameworkWork team</p>
 * @author 李志峰  电话:13824431576 程伟杰 电话:
 * @version 1.0
 */
public final class ConnectionFactory {
  private static ConnConfigure conf = new ConnConfigure();
  private static Connection con;

  /**
   * 提取连接(指定id)
   *
   * @param commit boolean
   * @param id String
   * @throws SpeedException
   * @return Connection
   */
  public static Connection getConnection(boolean commit, String id) throws
      SpeedException {   
	  con = conf.getConnection(id);
    try {
      
      con.setAutoCommit(commit);
    }
    catch (SQLException ex) {
      throw new SpeedException(ex);
    }

    return con;

  }

  /**
   * 提取连接
   *
   * @param commit boolean
   * @throws SpeedException
   * @return Connection
   */
  public static Connection getConnection(boolean commit) throws SpeedException {
    try {
      con = conf.getConnection();
      con.setAutoCommit(commit);
    }
    catch (SQLException ex) {
      throw new SpeedException(ex);
    }
    return con;
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?