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;
}
}