The JDBC Connector allows VMware GemFire to connect to external data sources with JDBC.
create database gemfire_db; use gemfire_db; create table parent(id bigint, name varchar(100), income double); insert into parent values (2, 'Parent_2', 987654321.0);
export CLASSPATH=/path/to/mysql-connector-java-8.0.15.jar:/path/to/gemfire-examples/jdbc/build/libs/jdbc.jar
gfsh run --file=scripts/start.gfsh
This will start the locator and two servers. And create Parent region, data source and JDBC mapping.
Parent
gfsh connect create data-source --name=mysql_data_source --url="jdbc:mysql://localhost/gemfire_db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC" --username=root --password="changeme" create jdbc-mapping --data-source=mysql_data_source --region=Parent --table=parent --pdx-name=com.vmware.gemfire.examples.jdbc.Parent --catalog=gemfire_db --id=id
../gradlew run
This will first put an entry with key 1 in Parent region. The entry will be propagated to MySQL’s parent table in database gemfire_db. Then it will invoke a get with key 2. Since Parent region does not have an entry with key equals 2, it will trigger JDBC Connector to load the entry from parent table in database gemfire_db from MySQL.
put
parent
gemfire_db
get
You can also use gfsh to connect to cluster and run the following commands: list data-source describe data-source list jdbc-mapping describe jdbc-mapping destroy jdbc-mapping destroy data-source
gfsh
list data-source
describe data-source
list jdbc-mapping
describe jdbc-mapping
destroy jdbc-mapping
destroy data-source
And use mysql to query the parent table.
mysql
gfsh run --file=scripts/stop.gfsh
To prevent this message from showing again, please enable pop-up blockers for support.broadcom.com or click Continue to proceed.