MySql Database not connected (unable to data retriew error showing)i followed Adobe cq Document | Community
Skip to main content
Level 2
October 16, 2015
Solved

MySql Database not connected (unable to data retriew error showing)i followed Adobe cq Document

  • October 16, 2015
  • 14 replies
  • 3700 views

Hi,

I followed in adobe cq5 document exactly store the data in my MySQL but i got problem in application when i am submitting user details it throw unable to retrieve  data i import every thing jquery files and js files can help me am new to cq5 below document i follow.

http://helpx.adobe.com/experience-manager/using/querying-persisting-cq-data-mysql.html

 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

This JSP code:

var url = location.pathname.replace(".html", "/_jcr_content.query.json") + "?filter="+ filter;

sends  a request to this JS file:

<%@include file="/libs/foundation/global.jsp"%>
<%@ page import="org.apache.sling.commons.json.io.*,org.w3c.dom.*" %><%
String filter = request.getParameter("filter");
    
com.adobe.aem.sql.CustomerServiceImp cs = new com.adobe.aem.sql.CustomerServiceImp();
 
String XML = cs.getCustomerData(filter); 
    
//Send the data back to the client
JSONWriter writer = new JSONWriter(response.getWriter());
writer.object();
writer.key("xml");
writer.value(XML);
    
writer.endObject();
%>

This JS file creates an object of type com.adobe.aem.sql.CustomerServiceImp. This Java class is bundled in the OSGi that you created. 

There are three places where something may be wrong:

1. You did not setup the connection class properly.

2. The drvier file is not bundled. 

3. The main page JSP is not finding the query.js file.

Please post your log file - we can tell what is happening from that. 

 

14 replies

smacdonald2008
Level 10
October 16, 2015

Try this article 

http://helpx.adobe.com/experience-manager/using/datasourcepool.html

 

The difference is you are using a DataSourcePool to connect instead of writing a custom connection handler.

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

Hi,

can you provide some logs (e.g. uploading somwhere and posting the link here?); it's hard to do a problem analysis based on the information you provided.

Thanks,
Jörg

smacdonald2008
Level 10
October 16, 2015

I just re-tested that article - it produced the following CQ app:

[img]client.png[/img]

If you are still having issues, email me at scottm@adobe.com. I can setup a connect session. 

Level 2
October 16, 2015

Hi ,

I followed that one also i tried more times but am not getting ,when i entered user details custId showing "Zero" and not adding details.

i have doubt in this jsp code

var ur = location.pathname.replace(".html", "/_jcr_content.query.json") 

can u explain i shared screen shot can u guide me how to  form  data storing Mysql database

Thanks.

smacdonald2008
Level 10
October 16, 2015

Also did you deploy a database driver file in an osgi bundle?

Level 2
October 16, 2015

Hi,

Thank you very much giving response.

i have server problem so i taken the backup of my  project, once done i try to implement document same u given. still if have any issue i will let u know.

 

Thank You

Level 2
October 16, 2015

Hi ,

I tried again same problem coming,kindly check i attached error log file .

 

Kindly help me once check.

 

Thanks

Level 2
October 16, 2015

Hi,

I added my application jar file and below jar files

javax.xml.stream-1.0.1

mysql-connector-java-5.1.22-bin

javax.xml-1.3.4

can u see attached Bundle Information

Level 2
October 16, 2015

please find error screen

smacdonald2008
Level 10
October 16, 2015

From your log file:

05.12.2014 21:02:52.095 *ERROR* [192.168.1.108 [1417793572064] GET /content/templatecustomer/_jcr_content.persist.json HTTP/1.1] com.day.cq.wcm.core.impl.WCMDebugFilter Error during include of SlingRequestPathInfo: path='/content/templatecustomer/jcr:content', selectorString='persist', extension='json', suffix='null' org.apache.sling.api.scripting.ScriptEvaluationException: 

 

It means that you have not setup the project files correctly. AEM cannot find persist.json file. Make sure you  setup all the files exactly as shown in the article. Looks like you missed this step in the article:

 

Create the persist.json.jsp
Add a new JSP file named persist.json.jsp to the following CQ path:

/apps/sqlquery/components/page/mysqlTemplate
The following code represents the persist.json.jsp file.


<%@include file="/libs/foundation/global.jsp"%>

<%@ page import="org.apache.sling.commons.json.io.*,com.adobe.cq.*" %><%
String first = request.getParameter("first");
String last = request.getParameter("last");
String address = request.getParameter("address");
String desc = request.getParameter("desc");
    
com.adobe.aem.sql.CustomerServiceImp cs = new com.adobe.aem.sql.CustomerServiceImp();
  
int myPK = cs.injestCustData(first, last, address, desc) ; 
     
//Send the data back to the client
JSONWriter writer = new JSONWriter(response.getWriter());
writer.object();
writer.key("pk");
writer.value(myPK);
    
writer.endObject();
%>