ORCentral

src/eu/coform/command/QueryIDofUniqueIDCommand.java

Go to the documentation of this file.
00001 package eu.coform.command;
00002 
00003 import java.sql.ResultSet;
00004 import java.sql.SQLException;
00005 
00006 import eu.coform.ORException;
00007 import eu.coform.UniqueID;
00008 import eu.coform.command.proto.Abstract;
00009 import eu.coform.database.Database;
00010 import eu.coform.database.Query;
00011 
00012 public class QueryIDofUniqueIDCommand implements Abstract {
00013 
00014    private UniqueID uuid;
00015    
00016    @Override
00017    public String execute() throws ORException {
00018       Query query = Database.getInstance().getNewQuery();
00019       query.setQuery("SELECT ID from `uuidtable` WHERE UUID = hex('" + getUuid().getId() + ")'");
00020       
00021       ResultSet set = Database.getInstance().query(query);
00022       
00023       try {
00024          if (!(set.isBeforeFirst() && set.isAfterLast()))
00025             set.next();
00026          else
00027             assert(false);
00028       } catch (SQLException e) {
00029          // TODO Auto-generated catch block
00030          e.printStackTrace();
00031       }
00032 
00033       String id = null;
00034       try {
00035          id = set.getString("ID");
00036       } catch (IllegalArgumentException e) {
00037          // TODO Auto-generated catch block
00038          e.printStackTrace();
00039       } catch (SQLException e) {
00040          // TODO Auto-generated catch block
00041          e.printStackTrace();
00042       }
00043       assert(id != null);
00044       return id;
00045    }
00046 
00047    public void setUuid(UniqueID uuid) {
00048       this.uuid = uuid;
00049    }
00050 
00051    public UniqueID getUuid() {
00052       return uuid;
00053    }
00054 
00055 }
 All Classes Namespaces Files Functions Variables Enumerations