Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

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

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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. 

 

View solution in original post

14 Replies

Avatar

Level 10

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.

Avatar

Employee Advisor

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

Avatar

Level 10

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. 

Avatar

Level 2

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.

Avatar

Level 10

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

Avatar

Level 2

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

Avatar

Level 2

Hi ,

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

 

Kindly help me once check.

 

Thanks

Avatar

Level 2

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

Avatar

Level 10

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();
%>

Avatar

Level 2

Hi ,

i followed what you say exactly.

i build in crxde component and template and jsp's same project struture  in Adobe  document.

but application not working.

 

thanks

Avatar

Level 10

Can you please post your CQ log file. There is a reason why the data is not being returned that leads to the JSON data. 

Avatar

Level 10

ZIP up your package and send to me at scottm@adobe.com. I want to look at your code then I will find out where the issue is. 

Avatar

Correct answer by
Level 10

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.