Menu

JDBC

cbx

Using JDBC

How to use

You can connect to Postgres-XC from Java programs using PostgreSQL JDBC Driver just like PostgreSQL.

It is available from the next link.

http://jdbc.postgresql.org/index.html

Limitations

Violating following rules will cause some exceptions.

  • Operations not compatible with Postgres-XC limitations will fail.
  • You must not set connection parameter "binaryTransfer" to true.

Testing JDBC

Description

Some of pgjdbc's official test will fail by the Postgres-XC limitations.

We adjusted it for compatibility test on Postgres-XC with JDBC. We describe how you can test using it.

How to test

Preconditions

  • You are already deployed a Postgres-XC cluster
    • The cluster grants user test to access database test. (pg_hba)
  • You have already installed Java VM, Java Compiler, Ant and JUnit

Prepare database

Create user and database for the test. You have other user and database for the test, you can skip this.

$ pgxc_ctl -- Createuser -s -d test
$ pgxc_ctl -- Createdb -U test test

Build a driver and tests

$TEST_HOME declares path to test.

$ git clone http://git.code.sf.net/p/postgres-xc/pgjdbc-xc $TEST_HOME/pgjdbc-xc
$ cd $TEST_HOME/pgjdbc-xc
$ ant testjar

Configure

Please replace Coordinator Address to your coordinator's IP address, Coordinator Port to port number your coordinator is listening.

$ cat > build.local.properties <EOF
binarytransfer=false
forcebinary=false
server=_Coordinator Address_
port=_Coordinator Port_
EOF

If you want to use other user and database, append them to your build.local.properties.

$ cat >> build.local.properties

Related

Postgres-XC: Developers_Page

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.