package classpackage;

import java.sql.*;

/**
 * Created by axelkvistad on 3/18/16.
 */
public class DBConnector {

    private String username = "thomjos"; //DataLeser2.lesTekst("Brukernavn: ");  // DataLeser2, se nedenfor
    private String password = "cinPn2AK";
    private String databaseName = "jdbc:mysql://mysql.stud.iie.ntnu.no:3306/" + username + "?user=" + username + "&password=" + password;
    private String databaseDriver = "com.mysql.jdbc.Driver";
    protected static Connection con = null;

    public DBConnector() {
        try {
            Class.forName(databaseDriver);
            con = DriverManager.getConnection(databaseName);
        } catch (ClassNotFoundException exc) {
            System.out.println(exc);
        } catch (SQLException exc) {
            System.out.println(exc);
        }
    }

    public void closeConnection() {
        try {
            con.close();
        } catch (SQLException exc) {
            System.out.println(exc);
        }
    }


}

@@ -527,24 +527,54 @@
 nnector() %7B%0A
+        if(con == null) %7B%0A    
         try 
@@ -567,32 +567,36 @@
           try %7B%0A
+    
             Clas
@@ -634,16 +634,20 @@
         
+    
 con = Dr
@@ -687,32 +687,36 @@
 eName);%0A        
+    
 %7D catch (ClassNo
@@ -742,32 +742,36 @@
 ) %7B%0A            
+ 
+   
 System.out.print
@@ -771,32 +771,36 @@
 t.println(exc);%0A
+    
         %7D catch 
@@ -824,32 +824,36 @@
 ) %7B%0A            
+ 
+   
 System.out.print
@@ -853,32 +853,46 @@
 t.println(exc);%0A
+            %7D%0A
         %7D%0A    %7D%0A

Fix so it doesn't create new connection if one has already been created.