package src;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.mysql.jdbc.Statement;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

public class SqlHelper {

  String user;
  String password;
  String server;
  String databaseName;
  MysqlDataSource dataSource;
  Connection connection;

  public SqlHelper(String user, String password, String server, String databaseName) {

    this.user = user;
    this.password = password;
    this.server = server;
    this.databaseName = databaseName;

    dataSource = new MysqlDataSource();
    dataSource.setUser(user);
    dataSource.setPassword(password);
    dataSource.setServerName(server);
    dataSource.setDatabaseName(databaseName);

  }

  public void connect() {
    try {
      connection = dataSource.getConnection();
      System.out.println("Connection Succesful ");

    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
  
  public void disconnect(){
      try {
	connection.close();
      System.out.println("Connection Closed");
      } catch (SQLException e) {
	  System.out.println("Exception on disconnect");
	e.printStackTrace();
      }
  }

  public void getUserID(int id) {

    Statement state;
    try {
      state = (Statement) connection.createStatement();
      System.out.println("getting info...");
//      ResultSet result = state.executeQuery("SELECT user_name, user_id, app01_id FROM UserRegistry WHERE app01_id IS NOT NULL AND id = " + id  + " LIMIT 10 ");
      ResultSet result = state.executeQuery("SELECT user_name, user_id, app01_id, app02_id FROM UserRegistry WHERE id = " + id  + " LIMIT 10 ");
      System.out.println("result acquired");
      result.next();
      System.out.println("result: " + result.getString(1) + " " + result.getString(2) + " " + result.getString(3) + " " + result.getString(4));
      result.close();
      state.close();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }

}

@@ -131,16 +131,45 @@
 eption;%0D
+%0Aimport java.util.ArrayList;%0D
 %0A%0D%0Aimpor
@@ -1298,20 +1298,33 @@
  public 
-void
+ArrayList%3CString%3E
  getUser
@@ -1335,24 +1335,83 @@
 nt id) %7B%0D%0A%0D%0A
+    ArrayList%3CString%3E userInfo = new ArrayList%3CString%3E();%0D%0A
     Statemen
@@ -2052,24 +2052,192 @@
 tring(4));%0D%0A
+      userInfo.add(result.getString(1));%0D%0A      userInfo.add(result.getString(2));%0D%0A      userInfo.add(result.getString(3));%0D%0A      userInfo.add(result.getString(4));%0D%0A
       result
@@ -2332,22 +2332,50 @@
 ();%0D%0A    %7D%0D%0A
+    %0D%0A    return userInfo;%0D%0A
   %7D%0D%0A%0D%0A%7D%0D%0A

Add ArrayList return to getUserID