Package dataaccess

Source Code of dataaccess.Groups

package dataaccess;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Hashtable;


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

public class Groups {
  private long group_id = 0;
  private String group_name = null;
 
  public static Hashtable <Long, String> getall_by_id_name()
  {
    MysqlDataSource l_ds = DBAccess.ReturnDataSource();
      Connection l_con = null;
      Statement l_stat = null;
      Hashtable <Long, String> l_id_names = new Hashtable<Long, String>();
     
      try
      {
        l_con = l_ds.getConnection();
      l_stat = l_con.createStatement()

       
      ResultSet s = l_stat.executeQuery("select group_id, group_name from groups");
     
      while (s.next())
      {
        l_id_names.put(s.getLong("group_id"), s.getString("group_name"));
      }
   
      }
      catch (Exception e)
      {
        return null;
      }
      finally
      {
        try {
        l_stat.close();
          l_con.close();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      }

      return l_id_names;
  }
 
  public void Group()
  {
  }

}
TOP

Related Classes of dataaccess.Groups

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.