Anyone please.

Thanks,
Noorul

On Monday, March 9, 2015 at 7:09:44 AM UTC+3, Noorul Farhan Ahmed wrote:
>
> Hi,
> I am getting the exception 
>  (com.orientechnologies.orient.core.exception.ODatabaseException) com.
> orientechnologies.orient.core.exception.ODatabaseException: Database 
> instance is not set in current thread. Assure to set it with: 
> ODatabaseRecordThreadLocal.INSTANCE.set(db);
>
> when I am trying to query using Java Document API. Here is how I am 
> querying the DB. 
>
> public List<ODocument> executeQuery(String sql, HashMap<String,Object> 
> params,StringBuilder errMsg) {
>         List<ODocument> result = new ArrayList<ODocument>();
>         try {
>             db = ODatabaseDocumentPool.global().acquire(connection,user, 
> password);
>             OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument
> >(sql);
>
>
>             if (params.isEmpty() == true) {
>                 result = db.command(query).execute();
>             } else {
>                 result = db.command(query).execute(params);
>             }
>
>
>         } catch (Exception e) {
>             errMsg.append(e.getMessage());
>             //TODO: Add threaded error log saving mechanism
>         } finally {
>             db.close();
>         }
>         return result;
>     }
>    
>   public boolean listItemExist(String userRID, String productRID, String 
> offerRID, ListItem listItem){
>         String sql;
>         List<ODocument> listItems;
>         HashMap<String, Object> params = new HashMap();
>         if (offerRID.equals("")){
>             sql = "select *, listName.name_ar as arlistname, 
> listName.name_en as enlistname from Inf_List_Item where userID = " + 
> userRID + " and productID = " + productRID;
>           
>         }
>         else {
>             sql = "select *, listName.name_ar as arlistname, 
> listName.name_en as enlistname from Inf_List_Item where userID = " + 
> userRID + " and productID = " + productRID + " and offerID =  " + offerRID
> ;
>            
>         }
>         StringBuilder errorMsg = new StringBuilder();
>         listItems = db.executeQuery(sql, params, errorMsg);
>         if (!errorMsg.toString().equals("")){
>             return false;
>         }
>         if (listItems.size() > 0){
>             ODocument listItemDoc = listItems.get(0);
>             listItem.setListItemRID(listItemDoc.field("@rid").toString());
>             listItem.setListNameAr(listItemDoc.field("arlistname").
> toString());
>             listItem.setListNameEn(listItemDoc.field("enlistname").
> toString());
>             listItem.setProductRID(productRID);
>             listItem.setOfferRID(offerRID);
>             return true;
>         }
>         else {
>             return false;
>         }
>     }
>
>  I get the error at 
> listItem.setListItemRID(listItemDoc.field("@rid").toString());
>
> Both methods are running on same thread. Any help is appreciated.
>
> Thanks,
> Noorul
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to