package conferenceOrganisation.database.connection;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

import javax.ejb.Singleton;

@Singleton
public class DatabaseConnection {

	public Statement createStatement() throws SQLException, IOException {

		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			System.out.println("No driver!");
		}

		Connection connection = null;

		try {
			Properties prop = new Properties();
			ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
			InputStream input = classLoader
					.getResourceAsStream("conferenceOrganisation/database/connection/config.properties");

			prop.load(input);

			String databaseUrl = String.format("jdbc:mysql://%s:%s/%s", prop.getProperty("databaseNetworkAddress"),
					prop.getProperty("databasePort"), prop.getProperty("databaseName"));

			connection = DriverManager.getConnection(databaseUrl, prop.getProperty("databaseUserAccount"),
					prop.getProperty("databasePassword"));
		} catch (SQLException e) {
			System.out.println("Connection failed");
		}

		if (connection != null) {
			System.out.println("Connected successfuly to the database.");
		} else {
			System.out.println("Connection failed.");
		}

		return connection.createStatement();
	}
	
	public Connection createConnection() throws IOException {
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			System.out.println("No driver!");
		}

		Connection connection = null;

		try {
			Properties prop = new Properties();
			ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
			InputStream input = classLoader
					.getResourceAsStream("conferenceOrganisation/database/connection/config.properties");

			prop.load(input);

			String databaseUrl = String.format("jdbc:mysql://%s:%s/%s", prop.getProperty("databaseNetworkAddress"),
					prop.getProperty("databasePort"), prop.getProperty("databaseName"));

			connection = DriverManager.getConnection(databaseUrl, prop.getProperty("databaseUserAccount"),
					prop.getProperty("databasePassword"));
		} catch (SQLException e) {
			System.out.println("Connection failed");
		}

		if (connection != null) {
			System.out.println("Connected successfuly to the database.");
		} else {
			System.out.println("Connection failed.");
		}
		
		return connection;
	}

}

@@ -1435,1088 +1435,6 @@
 %0A%09%7D%0A
-%09%0A%09public Connection createConnection() throws IOException %7B%0A%09%09try %7B%0A%09%09%09Class.forName(%22com.mysql.jdbc.Driver%22);%0A%09%09%7D catch (ClassNotFoundException e) %7B%0A%09%09%09System.out.println(%22No driver!%22);%0A%09%09%7D%0A%0A%09%09Connection connection = null;%0A%0A%09%09try %7B%0A%09%09%09Properties prop = new Properties();%0A%09%09%09ClassLoader classLoader = Thread.currentThread().getContextClassLoader();%0A%09%09%09InputStream input = classLoader%0A%09%09%09%09%09.getResourceAsStream(%22conferenceOrganisation/database/connection/config.properties%22);%0A%0A%09%09%09prop.load(input);%0A%0A%09%09%09String databaseUrl = String.format(%22jdbc:mysql://%25s:%25s/%25s%22, prop.getProperty(%22databaseNetworkAddress%22),%0A%09%09%09%09%09prop.getProperty(%22databasePort%22), prop.getProperty(%22databaseName%22));%0A%0A%09%09%09connection = DriverManager.getConnection(databaseUrl, prop.getProperty(%22databaseUserAccount%22),%0A%09%09%09%09%09prop.getProperty(%22databasePassword%22));%0A%09%09%7D catch (SQLException e) %7B%0A%09%09%09System.out.println(%22Connection failed%22);%0A%09%09%7D%0A%0A%09%09if (connection != null) %7B%0A%09%09%09System.out.println(%22Connected successfuly to the database.%22);%0A%09%09%7D else %7B%0A%09%09%09System.out.println(%22Connection failed.%22);%0A%09%09%7D%0A%09%09%0A%09%09return connection;%0A%09%7D%0A%0A
 %7D%0A

remove unused code