ORCentral

src/eu/coform/database/command/GetNewSessionUIDDBCommand.java

Go to the documentation of this file.
00001 package eu.coform.database.command;
00002 
00003 import java.sql.ResultSet;
00004 import java.sql.SQLException;
00005 
00006 import eu.coform.UniqueID;
00007 import eu.coform.database.DBException;
00008 import eu.coform.database.Database;
00009 import eu.coform.database.Query;
00010 
00014 public class GetNewSessionUIDDBCommand implements ResultDatabaseCommand {
00015 
00016    private UniqueID uid;
00017    
00018    public GetNewSessionUIDDBCommand(){
00019       uid = null;
00020    }
00021    
00022    
00028    @Override
00029    public void exec() throws DBException {
00030       Query query = Database.getInstance().getNewQuery();
00031        
00032       ResultSet set;
00033 
00034       try {
00035                 do
00036                   {
00037                      uid = UniqueID.randomUniqueID();
00038        
00039                      query.setQuery ("SELECT UserID FROM session WHERE UUID = " + "UNHEX('" + uid.toBin16() +"')");
00040                      set = Database.getInstance().query(query);
00041                     
00042                     
00043                   }while(set.next());
00044       } catch (IllegalArgumentException e) {
00045          throw new DBException(DBException.Error.QueryInvalid);
00046       } catch (SQLException e) {
00047          throw new DBException(DBException.Error.ObjectNotFound);
00048       }
00049 
00050             
00051 
00052       
00053    }
00054    @Override
00055    public UniqueID getResult() {
00056       return uid;       
00057    }
00058 
00059 }
00060 
00061 
00062 
 All Classes Namespaces Files Functions Variables Enumerations