Perforce JViews Gantt Sample: Resource Chart and JDBC
Description
This sample shows how to use the
ilog.views.model.table.IlvTableGanttModel
class to connect a resource-oriented Schedule chart to a JDBC-enabled
database in read/write mode.
How to Use the Sample
-
Configure the sample to use the MySQL Connector/J database driver:
- Download MySQL Connector/J from http://dev.mysql.com/downloads/connector/j/. This sample was developed with v5.1.17 of the connector, but any current version will work.
-
Copy the MySQL Connector/J jar file to the
<JVIEWS_HOME>/jviews-framework/lib/external
directory, where<JVIEWS_HOME>
is the root directory in which your Perforce JViews products are installed. -
Edit the
build.xml
Ant file of this sample. Search and replace the three references tomysql-connector-java-5.1.17-bin.jar
with the name of the MySQL Connector/J jar file that you downloaded. -
Rebuild the sample by running
build.bat
on Windows systems orbuild.sh
on other systems.
-
Configure and run MySQL server:
- Download the latest version of MySQL from http://dev.mysql.com/downloads/mysql/
-
Perforce recommends you do not restrict database access
for anonymous users.
If you do restrict database access, do the following before executing
the commands in the next steps:
- Login to your machine as a user with access rights to the test_ilog_demos database.
- Modify the source code for this sample to match the connection
information for an authorized user account. That is, change the
user and password static fields in
JdbcScheduleExample.java
to match the user account.
-
Launch MySQL server. This can be done by either:
- Running
mysqld
in the<MYSQL_HOME>/bin
subdirectory. - Starting the MySQL service in the Windows service administrative tool.
- Running
-
Install the initial data set by executing the following commands:
- In the system command line, navigate to the
<MYSQL_HOME>/bin
subdirectory. - Execute the
script.sql
SQL database creation script by either:- Open the MySQL command line by typing
mysql
. Then, at the interactive MySQL command line, runsource <JVIEWS_HOME>/jviews-gantt/samples/jdbcSchedule/resources/jdbc/script.sql
- At the system command line, run
mysql < <JVIEWS_HOME>/jviews-gantt/samples/jdbcSchedule/resources/jdbc/script.sql
<JVIEWS_HOME>
is the root directory in which your Perforce JViews products are installed. - Open the MySQL command line by typing
- In the system command line, navigate to the
- Run the sample.
- You can run several instances of the sample to test database synchronization.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
jdbc-schedule.jar
,
that allows you to execute the sample with a double click from a
file browser. Note that if you are using Internet Explorer, you can
open the installation directory
and execute the JAR file from the browser. This
technique may not work in other Web browsers.
Alternatively, you
can run the sample application from the command line.
First check that the Ant utility is properly configured. If not, see the
instructions on how to configure Ant for Perforce JViews.
Then, go to the installation directory
of the sample and type:
ant run
Topics Covered
- Using the JDBC Gantt model connected to a database.
Detailed Description
This sample shows how to use the
ilog.views.model.table.IlvTableGanttModel
class to roundtrip data to a database. It extends the
Schedule Chart
sample, found in the
<installdir>/samples/scheduleChart
directory.
This sample loads a Designer project file to get styling information from it
and then loads a set of data from a MySQL database. It adds actions that
allow you to:
- Commit the changes made to the database.
- Rollback uncommitted changes.
- Refresh the current model from the latest version of the database.
- Re-initialize the database content to the initial set of data.
Installation Directory
The Resource Chart and JDBC sample is installed here.
Classes Involved
- ilog.views.gantt.IlvGanttChart
- ilog.views.gantt.model.table.IlvTableGanttModel
- ilog.views.util.data.IlvRowSetTableModel
- ilog.views.util.data.IlvTableModelMapper
- ilog.views.gantt.model.jdbc.IlvJDBCGanttModel
Source Files
-
jdbc.JdbcScheduleExample
The main class of the sample. It extends the
ScheduleExample
. class. -
jdbc.JdbcScheduleActions
This file defines the actions necessary to deal with the database.
-
scheduleChart.ScheduleExample
The Gantt chart sample superclass.
-
shared.AbstractExample
The superclass of all Gantt samples.