ORCentral

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

Go to the documentation of this file.
00001 package eu.coform.database.command;
00002 
00003 import eu.coform.UniqueID;
00004 import eu.coform.database.DBException;
00005 import eu.coform.database.Database;
00006 import eu.coform.database.Query;
00007 
00008 
00009 
00010 public class NewSessionDBCommand implements DatabaseCommand {
00011            private UniqueID uuid;
00012            private long expiration_date;
00013            private long minutesTimeout;
00014            private long userId;
00015            private long locationId;
00016            private boolean primary;
00017            
00018            public NewSessionDBCommand(UniqueID uuid, long expiration_date, long minutesTimeout, long userId, long locationId, boolean primary){
00019               this.uuid = uuid;
00020               this.expiration_date = expiration_date;
00021               this.minutesTimeout = minutesTimeout;
00022               this.userId = userId;
00023               this.locationId = locationId;
00024               this.primary = primary;
00025            }
00031            @Override
00032            public void exec() throws DBException {
00033               Query query = Database.getInstance().getNewQuery();
00034               query.setQuery("INSERT INTO session VALUES (" 
00035                   + userId + "," + locationId + ", UNHEX('" + uuid.toBin16() + "'), DATE_ADD(FROM_UNIXTIME(" + expiration_date + "), INTERVAL " + minutesTimeout + " MINUTE), " + minutesTimeout + "," + (primary ? 1:0) + ")");  
00036               Database.getInstance().insert(query);
00037 
00038               
00039               
00040            }
00041 
00042 }
 All Classes Namespaces Files Functions Variables Enumerations