4

A client is trying to integrate some Broker Query code in to an existing web application. They have the following code:

public String doItNow(int keyA,
                      String schemaA,
                      String templateIdA) throws Exception {

    loggerInfo("doItNow.start" +
               ", key:" + keyA +
               ", schema:" + schemaA +
               ", templateId:" + templateIdA);
    StringBuffer sb = new StringBuffer();

    PublicationCriteria pubCriteria = new PublicationCriteria(keyA);
    loggerInfo("doItNow.PC:" + pubCriteria);

    SchemaTitleCriteria schemaTitleCriteria = new SchemaTitleCriteria(schemaA);
    loggerInfo("doItNow.STC:" + schemaTitleCriteria);

    AndCriteria andCriteria = new AndCriteria(pubCriteria, schemaTitleCriteria);
    loggerInfo("doItNow.AC:" + andCriteria);

    Query query = new Query();
    loggerInfo("doItNow.Query.0:" + query);
    query.setCriteria(andCriteria);
    loggerInfo("doItNow.Query.1:" + query);

    String[] results = query.executeQuery();
    for (String r : results) {
        loggerInfo("doItNow.\tres:" + r);
    }

    ComponentPresentationAssembler cpa = new ComponentPresentationAssembler(keyA);
    loggerInfo("doItNow.CPA:" + cpa);

    for (String item : results) {
        loggerInfo(":>" + item);
        sb.append(cpa.getContent(item, templateIdA));
    }

    return sb.toString();
}

The code exectues as far as creating the Query object:

Query query = new Query();

At this point it hangs. No errors appear in the cd_core log file to suggest a reason for this. Can anyone suggest areas where can investigate to debug this further, or suggest a solution?

Jeremy Grand-Scrutton
  • 2,802
  • 14
  • 20
  • 1
    May be worth checking. What version of JRE is being used? Version 1.6.0.29 has some issues with jdbc driver connecting to DB. I hope that is not the case here. – Ram G Oct 11 '12 at 13:08
  • Ram, this is it - the logs say "java.runtime.version = 1.6.0_29-b11". Post the answer and I'll accept it :) – Jeremy Grand-Scrutton Oct 11 '12 at 13:16

3 Answers3

7

There was known issue with JRE version 1.6.0.29 and MSSQL jdbc driver. You need to either downgrade or upgrade to a different JRE version.

https://forums.oracle.com/forums/thread.jspa?threadID=2301826

The issue seems very similar to the issue reported with the driver and you do not see any error messages either.

Ram G
  • 4,829
  • 1
  • 16
  • 26
0

Try changing the following line:

query.setCriteria(andCriteria);

to:

query.Criteria = andCriteria;

The SDL LiveContent example has a comment suggesting this change.

http://sdllivecontent.sdl.com/LiveContent/content/en-US/SDL_Tridion_2011_SPONE/concept_0AB6D192D7AB4EC18892631F519EF1DD

0

Have you added the correct includes? (Tridion.ContentDelivery.DynamicContent.Query Namespace) Also as suggested by Chris, query in tridion 2011 does not have a property as setCriteria. Use query.Criteria instead. Also have you implemented the necessary changed in cd_storage_conf.xml?

Huston Lopes
  • 622
  • 4
  • 17