Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

JDBC Query on subspace space

Hello All, Here is my story: I have N partitions of data that keeps unrelated partitions of my data. With the space, I deploy also some Services. On every partitions there are my services. One method of the service, is supposed to do some calculations on collocated space (on single partition) - the local one - and return result to the caller. The caller – client - ask for service method in broadcast mode (so we invoke the same method on every partition) and do reducing results from all subspaces.

Q1: Can I expect this method invocation schema to take approximate time that take of the calculations on the slowest partition. So even if my N is big - as the invocation will be done parallel, it will take time of the slowest one (+ extra time for reducing phase) ?

Q2. When dealing with the service method and my calculations, I need to use JDBC Query to perform those, however it seems that I cannot create JDBC Query on partition (in opposite to the query for whole space):

When I do:

    String url = "jdbc:gigaspaces:url:jini://*/space_container1/space?groups=gigaspaces-7.1.0-XAPPremium-ga&ignoreValidation=true&total_members=2,0&cluster_schema=partitioned&id=1&schema=default&locators=jini://myip:4164/,,myip&state=started";

    DriverManagerDataSource dataSource = new DriverManagerDataSource();

    String q = "SELECT schema.A.name FROM schema.A, schema.B WHERE schema.A.uniqueId = schema.B.id and schema.B.tasks<5";
    String q1 = Utils.fixSqlQuery(q);
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource, false);

    final List<String> ids = jdbcTemplate.query(q1, new RowMapper() {
        public Object mapRow(ResultSet rs, int number) throws SQLException {
            return rs.getString(1);

I set explicit URL for partition – not whole space, and it returns me result for whole space – I don’t want to do that. I want to compute result on every sub-partition in parallel and that client will reduce results.

(btw, it must be doable – UI can query single partition..). Can you help ?


Edited by: wrona jan on Jun 13, 2010 7:29 PM

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3441]{quote}

asked 2010-06-13 19:27:18 -0500

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

See the GSConnection.getInstance method. It can be used to pass IJSpace for the embedded space proxy.


answered 2010-06-18 17:25:02 -0500

shay hassidim gravatar image
edit flag offensive delete link more


Can somebody answer this ? Should I assume that there is possibility to perform JDBC Query on single partition ?

Thanks, Jan

answered 2010-06-18 09:14:38 -0500

edit flag offensive delete link more


You can get a GigaSpaces JDBC connection from a space proxy using the com.j_spaces.jdbc.driver.GConnection: {code} IJSpace gsSpaceProxy; //your space proxy. You can get it using GigaSpace.getSpace() GConnection connection = GConnection.getInstance(gsSpaceProxy); connection.setUseSingleSpace(true); //false = cluster, true=single {code}

The {{setUseSingleSpace}} allows you to get a JDBC connection that encapsulates a clustered proxy or to an embedded space proxy.

You can also use the following {{GConnection}} method to set the user and password for a secured space: {code} public static Connection getInstance(IJSpace space, String username, String password) throws SQLException {code}


shay hassidim gravatar imageshay hassidim ( 2010-06-18 20:55:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2010-06-13 19:27:18 -0500

Seen: 63 times

Last updated: Jun 18 '10