When using transaction and read-only with the system, the read-only never
seems to pickup transaction changes.  

I have tried different approaches to no avail.  The only thing that seems to
work is restarting the SEDNA instance.

I don't know if the problem is a bug, or I am just missing something.

The following code demonstrates the behavior.

MyCustomers.xml
    <?xml version="1.0" standalone="yes"?>
    <Customers>
    </Customers>


package sednadb.test;

import ru.ispras.sedna.driver.DatabaseManager;
import ru.ispras.sedna.driver.DriverException;
import ru.ispras.sedna.driver.SednaConnection;
import ru.ispras.sedna.driver.SednaSerializedResult;
import ru.ispras.sedna.driver.SednaStatement;


public class SednaConnectionResponseTest {

    public static void main(final String[] args) {
        SednaConnectionResponseTest test = new
SednaConnectionResponseTest();
        test.run();
    }

    private void run() {
        // Simple SEDNA request
        try {
            SednaConnection queryConnection = getConnection(true);
            runStatement(queryConnection, "doc(\"MyCustomers.xml\")");
            queryConnection.close();

            SednaConnection insertConnection = getConnection(false);
            runStatement(insertConnection, "update insert
<customer><id>5</id><name>Carpet cleaner</name><state>GA</state></customer>
into doc(\"MyCustomers.xml\")/Customers");
            insertConnection.close();

            // NOTE: New connection, but does not see the newly inserted
data.  
            // The test can be executed over and over, and the inserted
lines will never appear
            SednaConnection queryConnection2 = getConnection(true);
            runStatement(queryConnection2, "doc(\"MyCustomers.xml\")");
            queryConnection2.close();

        } catch (DriverException e) {
             System.out.println(e.toString());
             System.out.println(e.getDebugInfo());
        }

    }

    protected void runStatement(final SednaConnection connection, final
String statement)
            throws DriverException {
 
System.out.println("-----------------------------------------------");
        System.out.println(statement);
        connection.begin();
        SednaStatement st1 = connection.createStatement();
        StringBuffer sb = new StringBuffer();
        boolean call_res = st1.execute(statement);
        if (call_res) {
            SednaSerializedResult pResult = st1.getSerializedResult();
            if (pResult != null) {
                String item;
                while ((item = pResult.next()) != null) {
                    sb.append(item);
                }
            } else {
                System.out.println("statement.getSerializedResult() is
null");
            }
        }
        connection.commit();
        System.out.println(sb.toString());
    }


    protected SednaConnection getConnection(final boolean readonly) throws
DriverException {
        SednaConnection con = DatabaseManager.getConnection("localhost",
"mydata", "SYSTEM", "MANAGER");
        con.setTraceOutput(true);
        con.setDebugMode(true);
        con.setReadonlyMode(readonly);
        return con;
    }
}


Thanks,
Malcolm


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to