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;
  MysqlDataSource dataSource;
  Connection connection;
  
  public SqlHelper(String user, String password, String server){
    
    this.user = user;
    this.password = password;
    this.server = server;
    
    dataSource = new MysqlDataSource();
    dataSource.setUser(user);
    dataSource.setPassword(password);
    dataSource.setServerName(server);
    dataSource.setDatabaseName("FBminer2");
    
    
  }
  
  public void connect(){
    try {
      connection = dataSource.getConnection();
      System.out.println("Connection Succesful ");
      
      Statement 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 LIMIT 10 ");
      System.out.println("result acquired");
      result.next();
      System.out.println("result: " + result.getString(1) + " " + result.getString(2) + " " + result.getString(3));
      result.close();
      state.close();
      connection.close();
      
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }

}

@@ -251,18 +251,16 @@
 lper %7B%0D%0A
-  
 %0D%0A  Stri
@@ -307,16 +307,40 @@
 erver;%0D%0A
+  String databaseName;%0D%0A
   MysqlD
@@ -388,18 +388,16 @@
 ction;%0D%0A
-  
 %0D%0A  publ
@@ -452,24 +452,42 @@
 g server
-)%7B%0D%0A    
+, String databaseName) %7B%0D%0A
 %0D%0A    th
@@ -561,24 +561,59 @@
 erver;%0D%0A    
+this.databaseName = databaseName;%0D%0A
 %0D%0A    dataSo
@@ -787,41 +787,31 @@
 ame(
-%22FBminer2%22);%0D%0A    %0D%0A    
+databaseName);%0D%0A
 %0D%0A  %7D%0D%0A
-  
 %0D%0A  
@@ -831,16 +831,17 @@
 onnect()
+ 
 %7B%0D%0A    t
@@ -950,31 +950,397 @@
 );%0D%0A
+%0D%0A
     
-  %0D%0A      Statement
+%7D catch (SQLException e) %7B%0D%0A      e.printStackTrace();%0D%0A    %7D%0D%0A  %7D%0D%0A  %0D%0A  public void disconnect()%7B%0D%0A      try %7B%0D%0A%09connection.close();%0D%0A      System.out.println(%22Connection Closed%22);%0D%0A      %7D catch (SQLException e) %7B%0D%0A%09  System.out.println(%22Exception on disconnect%22);%0D%0A%09e.printStackTrace();%0D%0A      %7D%0D%0A  %7D%0D%0A%0D%0A  public void getUserID(int id) %7B%0D%0A%0D%0A    Statement state;%0D%0A    try %7B%0D%0A     
  sta
@@ -1383,26 +1383,24 @@
 atement();%0D%0A
-%0D%0A
       System
@@ -1558,16 +1558,37 @@
 NOT NULL
+ AND id = %22 + id  + %22
  LIMIT 1
@@ -1828,43 +1828,8 @@
 );%0D%0A
-      connection.close();%0D%0A      %0D%0A
     

Move query code to getUserID(), add disconnect()