Hi All,
As discussed, I am trying to migrate from Jena 2 to Jena 3. As part of that we 
are trying to eliminate usage of com.hp.hpl.jena.db.IDBConnection and rather 
use org.apache.jena.sdb.sql.SDBConnection 
Following is the method that we have written to get 
org.apache.jena.rdf.model.Model object from database

    private Model getModelFromRDFStore(String modelName, java.sql.Connection 
conn)        
    {
                org.apache.jena.sdb.StoreDesc storeDesc = new 
org.apache.jena.sdb.StoreDesc(org.apache.jena.sdb.store.LayoutType.LayoutTripleNodesIndex,
                                org.apache.jena.sdb.store.DatabaseType.Oracle) ;
                org.apache.jena.sdb.Store store = null;
                try {
                        store = 
org.apache.jena.sdb.SDBFactory.connectStore(conn, storeDesc);
                } catch (java.sql.SQLException e) {
                        e.printStackTrace();
                }
                org.apache.jena.query.Dataset dataset = 
org.apache.jena.sdb.SDBFactory.connectDataset(store);
                Model model = null;
                if (!dataset.containsNamedModel(modelName)) {
                        model = dataset.getDefaultModel();
                        dataset.addNamedModel(modelName, model);
                }
                else {
                        model = dataset.getNamedModel(modelName);
                }
                return model;
    }

But while checking for model in a dataset -> 
(!dataset.containsNamedModel(modelName)), we are getting the following error:
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not 
exist

Attached is the detailed exception. From the log it seems that some tables like 
Nodes N_1,  Quads Q_1 , Nodes R_1, Nodes R_2 are missing. 
So can anyone please tell what all tables (with columns) should we create to 
fix this issue?

Regards,
Ashwani



On 09/01/20, 8:07 PM, "Andy Seaborne" <[email protected]> wrote:

    Hi Ashwani,
    
    What are you trying to achieve overall?
    
    Is it to port an existing application/system from Jena 2.6 to Jena
    3.current?
    Or is it create a general adaptor for Jena to Oracle Spatial RDF?
    
    The answers to your questions are different depending on use case.
    
    If it is the latter, then going down the SDB route may lead to a whole host
    of problems because SDB is not deeply integrated into Jena anymore.  For
    example: transactions (and integration with Fuseki will be hard), newer
    APIs like RDFConnection. You want to implement DatasetGraph and
    Transactional. I doubt the database framework DBOE helps much but it is
    worth checking that to see if it will save you work.
    
    If it is a one-off conversion for a specific application,  things are
    simpler because it's getting something to work for one, known case rather
    arbitrary application use cases in the future and as Jena evolves.
    ------------
    Re: SDBConnection
    
    SDBConnection does not control the table naming. That's in the "FmtLayout"
    classes.
    
    Re:LayoutType
    
    See the source code.
    SDB uses one of three fixed table layouts. layout1 (really, *really* don't
    use), layout2/index and layout2/hash.
    
    The SPARQL to SQL code generation is specific to the layout.
    
    
    On Thu, 9 Jan 2020 at 12:24, Ashwani Rathi <[email protected]> wrote:
    
    > Thanks for the reply.
    >
    > Also in jena 2, we can set TableNamePrefix on an IDBConnection with the
    > following statements:
    >
    >                 IDBConnection conn = null;
    >                 IRDBDriver driver = conn.getDriver();
    >                 driver.setTableNamePrefix("prefix");
    >
    > So what actually does this achieve. And how can we achieve the same
    > functionality in jena 3 with org.apache.jena.sdb.sql.SDBConnection class?
    >
    > Regards,
    > Ashwani
    >
    > On 09/01/20, 2:15 PM, "Bögershausen, Merlin Michael" <
    > [email protected]> wrote:
    >
    >     Hi,
    >
    >     You can check whether the dataset contains a specific named model with
    > dataset.containesNamedModel() [1]
    >
    >
    >
    >     Best Merlin
    >
    >
    >
    >     [1]
    > 
https://urldefense.proofpoint.com/v2/url?u=https-3A__jena.apache.org_documentation_javadoc_arq_org_apache_jena_query_Dataset.html-23containsNamedModel-2Djava.lang.String-2D&d=DwIGaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=ld8gXdwUlVansMT0flGoGNN0AOkhQba_hAJM5PewJCA&m=_5kPj72-EHVEVxkEWZfp9umEDalFfeUoHIdfCCb9Plo&s=HB2xzUCShqe8JzEhH_9HaUktJ5rnUU2XOCqrcL6wOe8&e=
    >
    >
    >
    >
    >
    >     Am 09.01.2020 06:59 schrieb Ashwani Rathi <[email protected]>:
    >
    >     Hi All,
    >
    >     We are upgrading from jena 2 to jena 3.
    >
    >     We have the following method in com.hp.hpl.jena.db.IDBConnection in
    > jena 2:
    >
    >
    >
    >
    > 
------------------------------------------------------------------------------------------------------------
    >
    >     containsModel
    >
    >
    >
    >     boolean containsModel(String name)                      throws
    > RDFRDBException
    >
    >
    >
    >         Test if a given model is contained in the database.
    >
    >
    >
    >         Parameters:
    >
    >             name - the name of a model which may be in the database
    >
    >         Returns:
    >
    >             Boolean true if the model is contained in the database
    >
    >         Throws:
    >
    >             RDFDBException
    >
    >             RDFRDBException
    >
    >         Since:
    >
    >             Jena 2.0
    >
    >
    > 
------------------------------------------------------------------------------------------------------------
    >
    >     This method is used to check whether a given model exists in the
    > underlying database.
    >
    >
    >
    >     So is there a corresponding method to check for models in database in
    > jena 3 in org.apache.jena.sdb.sql.SDBConnection.java class or in any other
    > jena 3 jar?
    >
    >
    >
    >     Regards,
    >
    >     Ashwani
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    

Attachment: exception.docx
Description: MS-Word 2007 document

Reply via email to