package org.csstudio.alarm.dbaccess.archivedb;

import org.csstudio.platform.AbstractCssPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;


/**
 * The activator class controls the plug-in life cycle
 */
public class Activator extends AbstractCssPlugin {

	// The plug-in ID
	public static final String PLUGIN_ID = "org.csstudio.diag.jmssender";

	// The shared instance
	private static Activator plugin;
	
	/**
	 * The constructor
	 */
	public Activator() {
		plugin = this;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	 */
	public void doStart(BundleContext context) throws Exception {
//		super.start(context);
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
	 */
	public void doStop(BundleContext context) throws Exception {
		plugin = null;
//		super.stop(context);
	}

	/**
	 * Returns the shared instance
	 *
	 * @return the shared instance
	 */
	public static Activator getDefault() {
		return plugin;
	}

	/* (non-Javadoc)
	 * @see org.csstudio.platform.ui.AbstractCssUiPlugin#getPluginId()
	 */
	@Override
	public String getPluginId() {
		// TODO Auto-generated method stub
		return PLUGIN_ID;
	}
	
	/** Add informational message to the plugin log. */
    public static void logInfo(String message)
    {
        getDefault().log(IStatus.INFO, message, null);
    }

    /** Add error message to the plugin log. */
    public static void logError(String message)
    {
        getDefault().log(IStatus.ERROR, message, null);
    }

    /** Add an exception to the plugin log. */
    public static void logException(String message, Exception e)
    {
        getDefault().log(IStatus.ERROR, message, e);
    }

    /** Add a message to the log.
     * @param type
     * @param message
     */
    private void log(int type, String message, Exception e)
    {
        getLog().log(new Status(type, PLUGIN_ID, IStatus.OK, message, e));
    }

}

@@ -41,16 +41,106 @@
 ivedb;%0A%0A
+import java.sql.Connection;%0Aimport java.sql.DriverManager;%0Aimport java.sql.SQLException;%0A%0A
 import o
@@ -179,16 +179,16 @@
 Plugin;%0A
-
 import o
@@ -416,16 +416,65 @@
 Plugin %7B
+%0A%09%0A%09private Connection databaseConnection = null;
 %0A%0A%09// Th
@@ -1075,16 +1075,88 @@
 ption %7B%0A
+%09%09if ( databaseConnection != null) %7B%0A%09%09%09databaseConnection.close();%0A%09%09%7D%0A
 %09%09plugin
@@ -2262,17 +2262,367 @@
 e, e));%0A
-
     %7D%0A%0A
+%09public Connection getDatabaseConnection( String url, String user, String password) %7B%0A%09%09%0A%09%09if (databaseConnection== null) %7B%0A%09%09%09try %7B%0A%09%09%09%09this.databaseConnection = DriverManager.getConnection(url, user, password);%0A%09%09%09%7D catch (SQLException e) %7B%0A%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return databaseConnection;%0A%09%7D%0A%0A%0A
 %7D%0A

Add connection to database here This way we get a permanent connection - no reconnect for each request - permanent connection (which harald might not like)