access eXtremedb in JNI Through SQL


Principalsteps are:

1) Java application which establishes eXtremeDB database instance should createdatabase in shared memory. Database open flag 'Database.MCO_CFG_SHARED_MEMORY'and memory device class 'Database.SharedMemoryDevice' should be used instead ofordinary memory device class 'Database.PrivateMemoryDevice'. See sample'samples/java/open' and sample command line option 'shm' for detailedexplanation.

2) Utility 'xsql' (samples/native/sql/xsql) should be built using eXtremeDBshared memory library. Just compile the sample with option PRJ_MEMDEV=SHARED onUnix. On Windows check in sample's VisualStudio project properties that library'mcomw32.lib / mcomw32_debug.lib' is linked instead of library 'mcomconv.lib /mcomconv_debug.lib'. And then compile the sample.

3) Start Java application first. Then start 'xsq' utility to connect to adatabase created by Java application and share it via remote SQL interface.Connect to eXtremeDB SQL server using rSQL C API native interface or ODBC orJDBC drivers. See SQL documentation and sample 'samples/jdbc' for furtherexplanations.

4) As Java application and 'xsql' utility use the same data structures inshared memory always use the same eXtremeDB distributive to build bothapplications. Transaction manages (MURSIW/MVCC), synchronization libraries andin-memory/disk libraries set must be the same for both applications too.


Example scenario 'from a box' using standard samples:
1) Compile Java application 'samples/java/open' using script'samples/java/compile'
2) Compile 'samples/native/sql/xsql' utility by command 'gmakePRJ_MEMDEV=SHARED DEBUG=on all' on Linux or using Visual Studio on Windows.Check Visual Studio project properties that library 'mcomw32_debug.lib' islinked instead of library 'mcomconv_debug.lib'.
3) Make a copy of original file 'SimpleJDBC.java' and replace it by patchedversion which is attached to this email.
4) Compile sample 'samples/jdbc' using script 'samples/jdbc/compile'.
5) Go to directory 'samples/java/open' and start Java application by commandline 'Open.bat debug shm' (or 'Open.sh debug shm').
6) In another console go to root directory of eXtremeDB installation and startSQL server application 'target/bin/xsql opendb:5001' (on port 5001).
7) Type into xsql console 'select * from Metatable;' to print databasestructure and double-check connection to a database created by sample 'open'.Output should be like this:
XSQL>select * from Metatable;
TableName       FieldNo FieldName       FieldTypeName  FieldType       FieldSize       AutoGenerated  ReferencedTable
------------------------------------------------------------------------------
OpenObj 1       i4      Int4   6       0       false  null
Selected records: 1

8) In another console go to directory 'samples/jdbc' and start JDBC sample'SimpleJDBC.bat' (or 'SimpleJDBC.sh'). It should print the same databasecontent using remote SQL connection. Output should be like this:
Connecting to Database URL = jdbc:extremedb:localhost
Connected...
TableName       FieldNo FieldName
OpenObj 1       i4
--------------
Now closing the connection

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值