I read a discussion about the thread safety of BaseConnector - Tim Huang commented that it’s not thread safe. From my read of the code, he seems right. Here is his comment:
docs.dhtmlx.com/doku.php?id=dhtm … 125941acb3
I wonder if there is any new code addressing thread safety? It would be great if somebody can comment on this issue. Many thanks!
In February we will release updated version.
You can try it now - the attached jar file has full backward compatibility, and in addition to other updates allow to create thread safe connectors
[code] public class Grid_01_BasicConnector_TS extends ThreadSafeConnectorServlet {
@Override
protected void configure(HttpServletRequest req, HttpServletResponse res) {
Connection conn = ( new DataBaseConnection()).getConnection();
GridConnector c = new GridConnector(conn);
c.servlet(req,res);
c.dynamic_loading(100);
c.render_table("grid50000", "item_id", "item_nm,item_cd");
}
}[/code]
a) use ThreadSafeConnectorServlet as base class
b) one extra command is required during connector init - c.servlet(req,res);
dhtmlxconnector.zip (163 KB)
Hi,
I am using ThreadSafeConnector instead of connector servlet, till now everything is fine , but when I am trying to add the data the servlet is throwing some exception.I am not able to solve.Pls help me in this regard.Here is the stack trace of it.
java.lang.ClassCastException: com.dhtmlx.connector.GridConnector cannot be cast to com.dhtmlx.connector.CommonConnector
com.dhtmlx.connector.DataProcessor.get_status(DataProcessor.java:158)
com.dhtmlx.connector.DataProcessor.process(DataProcessor.java:120)
com.dhtmlx.connector.BaseConnector.render(BaseConnector.java:292)
com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:210)
com.dhtmlx.connector.BaseConnector.render_table(BaseConnector.java:178)
com.kentropy.dhtmlxConnector.DhtmlxConnector.configure(DhtmlxConnector.java:29)
com.dhtmlx.connector.ThreadSafeConnectorServlet.doGet(ThreadSafeConnectorServlet.java:18)
com.dhtmlx.connector.ThreadSafeConnectorServlet.doPost(ThreadSafeConnectorServlet.java:25)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
Thankyou,
Ravi.
Above message is quite strange
a) there is no any type casting at line 158 in DataProcessor.java
b) event if it was here - the CommonConnector is a base class for GridConnector, so casting must not be a problem.
Which java server you are using?
I am using apache tomcat 5.5 and jdk 1.5 .Here is the code snippet of how I am using the Threadsafeconnector.
public class DynamicLoader extends ThreadSafeConnectorServlet {
@Override
protected void configure(HttpServletRequest req, HttpServletResponse res) {
Connection conn = DBConnection.getConnection();
GridConnector gc = new GridConnector(conn);
gc.servlet(req,res);
gc.dynamic_loading(50);
gc.render_table("accounts", "id", "usernam,password");
}
}
The init code is correct as well.
The connector.jar in the package was compiled against jdk 1.6 ( and tested with Tomcat, by the way ) - so maybe you need to recompile it against jdk 1.5 to resolve that problem ( not sure ). Jar file contains all sources inside.
I’ve compiled dhtmlxconnector.jar with jdk 1.5 , It solved my issue.Thank you very much.