DataConnector for java

dear team,

is DataConnector for DataStore available in java?

if it is, how to use the connector

thx :slight_smile:

dear team, i try using JSONCommonConnector, but it outputting xml declaration before the json data

<?xml version='1.0' encoding='utf-8' ?>
[{"id":"000001","agenda_no":"123","nomor_surat":"DB\/12\/VII\/2011\/01"},
"id":"000004","agenda_no":"124","nomor_surat":"123\/123\/123"}]

Fixed jar file is attached.
Sorry for inconvenience.
dhtmlxconnector.zip (173 KB)

Yep, grab the latest jar ( attached ) and you can use code like

[code]public class SimpleDataSource extends ThreadSafeConnectorServlet {

@Override
protected void configure(HttpServletRequest req, HttpServletResponse res) {
	Connection conn = ( new DataBaseConnection()).getConnection();
	
	CommonConnector data = new CommonConnector(conn);
	data.servlet(req, res);
	data.render_table("touch_users", "id", "name,age,group_name,city,phone,sex,driver_license");
}

}[/code]

or in case of json data stream

[code]public class JSONSimpleDataSource extends ThreadSafeConnectorServlet {

@Override
protected void configure(HttpServletRequest req, HttpServletResponse res) {
	Connection conn = ( new DataBaseConnection()).getConnection();
	
	JSONCommonConnector data = new JSONCommonConnector(conn);
	data.servlet(req, res);
	data.render_table("touch_users", "id", "name,age,group_name,city,phone,sex,driver_license");
}

}[/code]

Connector class support all features of other connectors ( behaviors, configuration options, etc. )
dhtmlxconnector.zip (173 KB)

is it support for DataStore connector?

once problem again, GridConnector failed to insert new data to database table, it return xml status error, but update and delete operation was done successfully

Yep, you can use CommonConnector or JSONCommonConnector to feed data in datastore ( and save updates through dataprocessor if necessary )

once problem again, GridConnector failed to insert new data to database table
Try to enable log - it seems as some database level error.

dear stanislav, i already enable logging, it says

INSERT INTO jenis (id,jenis_surat) VALUES ('','')

but there is no data inserted into tables, after i change the ‘id’ field on the grid, it trigger insert operation once more and log like this

====================================
Log started, Thu Aug 04 11:03:45 WIT 2011
====================================
DB query 
INSERT INTO jenis (id,jenis_surat) VALUES ('5','')


DB query 
SELECT LAST_INSERT_ID() as new_id

here is some detail

post data when addRow() function is invoked

1312430172234_gr_id=1312430172234
&1312430172234_c0=
&1312430172234_c1=
&1312430172234_!nativeeditor_status=inserted
&ids=1312430172234

response

<data><action type='error' sid='1312430172234' tid='1312430172234' ></action></data>

after change the ‘id’ field on the grid
post data

1312430611105_gr_id=1312430611105
&1312430611105_c0=5 //first cell change to '5', it should trigger update instead of insert
&1312430611105_c1=
&1312430611105_!nativeeditor_status=inserted
&ids=1312430611105

response

<data><action type='inserted' sid='1312430611105' tid='0' ></action></data>

servlet code

protected void configure(HttpServletRequest req, HttpServletResponse res) {
		// TODO Auto-generated method stub
		Connection con 	= dbConnection.getConnection();
		
		GridConnector grid= new GridConnector(con);
		grid.servlet(req, res);
		grid.enable_log("grid.log", true);
		grid.render_table("jenis", "id", "id,jenis_surat");
	}

It seems that you are using ID field as row ID and as editable value in one of columns.
Normal Grid connector will not allow such behavior ( by default it expect to have auto-increment id in database, which is not the situation in your case )

it’s still produce an error when i remove the id from the grid structure

[code]protected void configure(HttpServletRequest req, HttpServletResponse res) {
// TODO Auto-generated method stub
Connection con = dbConnection.getConnection();

	GridConnector grid= new GridConnector(con);
	grid.servlet(req, res);
	grid.enable_log("grid.log", true);
	grid.render_table("jenis", "id", "jenis_surat"); //exclude 'id' field from grid data
}[/code]

when new row inserted to grid, GridConenctor return xml status error instead of inserted

<data><action type='error' sid='1312507830624' tid='1312507830624' ></action></data>

but when i edit one field, GridConnector return xml status inserted instead of updated

<data><action type='inserted' sid='1312507830624' tid='9' ></action></data>

^
note: i edit the field from new inserted row

it only return an error status when blank row inserted, but when some data is included, it’s return inserted status

Still it doesn’t seems as a error of connector - check the table structure in database. Probably it has some fields set as “NOT EMPTY”