Package app.database.jdbc

Source Code of app.database.jdbc.MainConnection

package app.database.jdbc;

import java.sql.SQLException;

import javax.swing.JOptionPane;

import org.ytreza.data.database.jdbc.ConnectionNotDefinedException;
import org.ytreza.data.database.jdbc.JdbcConnectionManager;

public class MainConnection extends JdbcConnectionManager {
  private static MainConnection connection;
 
 
  private MainConnection(String name, String connectionInfo) throws ClassNotFoundException, SQLException {
    super(name, connectionInfo);
  }
 
  private MainConnection(String name, String connectionInfo, String user, String passwd) throws ClassNotFoundException, SQLException {
    super(name, connectionInfo, user, passwd);
  }

  public static void initMainConnection(String name, String connectionInfo, String user, String passwd) throws SQLException {
    try {
      connection = new MainConnection(name, connectionInfo, user, passwd);
    } catch (ClassNotFoundException e) {
      JOptionPane.showMessageDialog(null, "Impossible de charger le driver " + name + ".\n Veuillez-�diter le fichier de configuration.");
      e.printStackTrace();
    }
  }
 
  public static MainConnection getMainConnection () throws ConnectionNotDefinedException {
    if (connection == null) {
      throw new ConnectionNotDefinedException();
    }
    return connection;
  }
}
TOP

Related Classes of app.database.jdbc.MainConnection

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.