Configuring native drivers for DataWindow objects

CR #429820

Description: For production systems with a large number of concurrent users (200 or more), Sybase recommends using native drivers, which provide the advantage of using the ConnectionCache. JDBC can be used in production systems with fewer than 200 concurrent users.

For additional information, see JSF DataWindow Database Driver Support in the Sybase WorkSpace online bookshelf.

To improve performance, one option is to implement connection information sharing among multiple DataWindow objects across the Web application using the onLoadHandler attribute of the JSF DataWindow. Java coding is required.

StepsImplementing connection information sharing

  1. Define a common class that implements the DataWindowOnLoadListener:

    //For DataWindow Data Retrieval with no retrieval argumentspublic class CommonOnLoadHandler implements DataWindowOnLoadListener{	public TestODBC() {		super();	}	public void onLoadDataWindow(DWLoadedEvent arg0) {				//1. Get the DataWindowComponent from the ViewRoot		DataWindowComponent dwc = (DataWindowComponent)arg0.getComponent();				//2. Create JSFDW Transaction object		Transaction ts = new Transaction();		try {						//=================================================				//ODBC Transaction object				//ODBC Driver needs to be installed				ts.setDbms("ODBC");				ts.setDbparm("ConnectString='DSN=TestODBC;UID=sa;PWD=sa'");						//=================================================				//ASE Native Transaction object				//Need to have ASE Open Client Installed on the EAServer machine				 //ts.setDbms("SYC Adaptive Server Enterprise");				//ts.setDatabase("jsfdwtest");				//ts.setLogpass("sa");				//ts.setServername("TestASEOC"); //Created using DSEdit Utility				//ts.setLogid("sa");			//=================================================						ts.connect();		} catch (TransactionException e) {			ServletContext sc = (ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();			sc.log("TestODBCJava " + e.getMessage());					} catch (MethodFailureException e) {					}                //Cache JS files for performance improvement                FacesContext fc = FacesContext.getCurrentInstance();    	String contextPath = fc.getApplication().getViewHandler().getActionURL(fc,"/");    	int first = contextPath.indexOf("/");    	int last = contextPath.lastIndexOf("/");    	String refinedcontextPath= contextPath.substring(first,last+1);    	        try {	dwc.modify("DataWindow.HtmlGen.ResourceBase='" + refinedcontextPath + "'");        	dwc.modify("DataWindow.HtmlGen.CommonJSFile='common.js'");        	dwc.modify("DataWindow.HtmlGen.DateJSFile='date.js'");        	dwc.modify("DataWindow.HtmlGen.NumberJSFile='number.js'");        	dwc.modify("DataWindow.HtmlGen.StringJSFile='string.js'");		} catch (ArgumentNullException e) {					} 				//3. Attach the Transaction object to the DataWindowComponent		dwc.setTransaction(ts);				//4. Do Data Retrieval		try {			dwc.retrieve();		} catch (DbErrorException e) {			ServletContext sc = (ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();			sc.log("TestODBCJava " + e.getSqlErrorText());		}				//5. Disconnect the connection		dwc.getTransaction().disconnect();				//6. Null reference		ts=null;	}}
    
  2. Share the common handler among all the DataWindow objects in the Web application.

    For Page1.jsp:

    <syb:dataWindow onLoadHandler="CommonOnLoadHandler" dataWindowObject="dept"			libraryList="/WEB-INF/pb/test.pbl" id="dept1" enableLog="true">			<syb:objectlink linkname="dept_id" linkurl="/usingonloadhandler.faces">				<syb:linkargs value="dept_id" type="DW Column" name="dept"></syb:linkargs>			</syb:objectlink></syb:dataWindow><syb:dataWindow onLoadHandler="CommonOnLoadHandler" dataWindowObject="dept"			libraryList="/WEB-INF/pb/test.pbl" id="dept2" enableLog="true">			<syb:objectlink linkname="dept_id" linkurl="/usingonloadhandler.faces">				<syb:linkargs value="dept_id" type="DW Column" name="dept"></syb:linkargs>			</syb:objectlink></syb:dataWindow>
    

    For Page2.jsp:

    <syb:dataWindow onLoadHandler="CommonOnLoadHandler" dataWindowObject="cust"			libraryList="/WEB-INF/pb/test.pbl" id="cust1" enableLog="true">			</syb:dataWindow>