Hello.
the id column is set as a primary key and the autoincrement is enabled.
My XHTML :
[code] <h:outputScript name=“js/dhtmlxConnector_java/connector.js” />
<h:outputStylesheet name="dhtmlxgantt/codebase/dhtmlxgantt.css" />
<h:outputScript name="dhtmlxgantt/codebase/dhtmlxgantt.js" />
<h:outputScript name="dhtmlxgantt/codebase/locale/locale_fr.js" />
<div id="idConteneurGantt" style="width:100%; height:300px;">
</div>
<script>
gantt.config.xml_date = "%Y-%m-%d %H:%i";
gantt.config.scale_unit = "day";
gantt.config.duration_unit = "day";
gantt.config.date_scale = "%d";
gantt.config.scale_height = "130";
gantt.config.scale_row = "130";
gantt.init("idConteneurGantt");
gantt.load('/Poc/faces/data');
var dp = new dataProcessor('/Poc/faces/data');
dp.init(gantt);
</script>[/code]
My connector :
[code]package dhtmlx;
import java.sql.Connection;
import java.sql.DriverManager;
import com.dhtmlx.connector.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(name = “JSONDataServlet”, urlPatterns = {"/data"})
public class JsonGanttDataServlet extends ThreadSafeConnectorServlet {
@Override
protected void configure(HttpServletRequest req, HttpServletResponse res) {
System.out.println("JsonGanttDataServlet configure in");
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_dhtmlx", "root", "mysql");
} catch (Throwable e) {
e.printStackTrace();
}
JSONGanttConnector gantt = new JSONGanttConnector(conn, DBType.MySQL);
gantt.servlet(req, res);
gantt.mix("open", "1");
gantt.render_links("gantt_links", "id", "source,target,type");
gantt.render_table("gantt_tasks", "id", "start_date,duration,text,progress,parent");
System.out.println("JsonGanttDataServlet configure out");
}
}[/code]
My schema MySQL :
[code]-- MySQL Administrator dump 1.4
– Server version 5.0.45-community-nt
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /;
/!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 /;
/!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 /;
/!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=‘NO_AUTO_VALUE_ON_ZERO’ */;
–
– Create schema test_dhtmlx
CREATE DATABASE IF NOT EXISTS test_dhtmlx;
USE test_dhtmlx;
–
– Definition of table gantt_links
DROP TABLE IF EXISTS gantt_links
;
CREATE TABLE gantt_links
(
id
int(11) NOT NULL auto_increment,
source
int(11) NOT NULL,
target
int(11) NOT NULL,
type
varchar(1) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
–
– Dumping data for table gantt_links
/*!40000 ALTER TABLE gantt_links
DISABLE KEYS /;
/!40000 ALTER TABLE gantt_links
ENABLE KEYS */;
–
– Definition of table gantt_tasks
DROP TABLE IF EXISTS gantt_tasks
;
CREATE TABLE gantt_tasks
(
id
int(11) NOT NULL auto_increment,
text
varchar(255) NOT NULL,
start_date
datetime NOT NULL,
duration
int(11) NOT NULL,
progress
float NOT NULL,
sortorder
int(11) NOT NULL,
parent
int(11) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
–
– Dumping data for table gantt_tasks
/*!40000 ALTER TABLE gantt_tasks
DISABLE KEYS /;
INSERT INTO gantt_tasks
(id
,text
,start_date
,duration
,progress
,sortorder
,parent
) VALUES
(1,‘Tâche 1’,‘2014-01-06 00:00:00’,13,0.965934,0,0),
(3,‘Tâche 1-1’,‘2014-01-16 00:00:00’,9,0.0238095,0,1),
(4,‘aaaa’,‘2014-01-06 00:00:00’,5,0.5,0,0),
(5,‘bbb’,‘2014-02-06 00:00:00’,25,0.25,0,0);
/!40000 ALTER TABLE gantt_tasks
ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE /;
/!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS /;
/!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS /;
/!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /;
/!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /;
/!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION /;
/!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
[/code]