Running a SPARQL query across all models

Is there a concise way of running a SPARQL query against all models in the database (or at least all models owned by a db user) via the Oracle Jena Adapter? Do I have to manually find all models, add them to a GraphOracleSem, and pass a composite model (from the graph) to a QueryFactory.create() method or is there a simpler way like something synonymous to DatasetStore.create() that would pass back the entire dataset?
Thanks

I want to run the query against a merged graph of all the models.
I see you can do this by attaching an Attachment containing the list of all model names to a graph. I could be dealing with several models. I really want to be able to query against the entire data set but this mean I must know the names of all the models (which means selecting from MDSYS>RDF_MODEL$). Here is the code I came up with. This gives me a Dataset that I can then pass to QueryExecutionFactory.create(Query, Dataset). Any suggestions?
private static final String SELECT_MODELS =
"SELECT model_name FROM MDSYS.RDF_MODEL$ WHERE owner=? and model_name != ?";
private static final String MODEL_NAME = "model_name";
* The name of a reserved model representing all semantic data in the database.
private static final String DATASET_MODEL_NAME = "DATASET";
public Dataset getDataSet() {
Dataset ds = null;
Oracle oracle = getOracle();
// The hard way: manually
try {
// Get all accessible models in the store
PreparedStatement stmt = oracle.getConnection().prepareStatement(SELECT_MODELS);
stmt.setString(1, oracle.getConnection().getUserName());
stmt.setString(2, DATASET_MODEL_NAME);
ResultSet rs = stmt.executeQuery();
// Add them to a composite model                    
List<String> modelNames = new ArrayList<String>();
while ( rs.next() ) {
modelNames.add(rs.getString(MODEL_NAME));          
stmt.close();
// create a dataset from the composite model
Attachment attachment = Attachment.createInstance(
(String[])modelNames.toArray(new String[0]),
new String[0],
InferenceMaintenanceMode.NO_UPDATE,
QueryOptions.QUERY_VALID_ONLY );
GraphOracleSem graph = new GraphOracleSem( oracle,
DATASET_MODEL_NAME, attachment );
ds = DatasetFactory.create(new ModelCom(graph));
} catch (SQLException e) {
log.warn("SQL Exception caught", e);               
} catch (Exception e) {
log.warn("Exception thrown.", e);
return ds;
Thanks!

Similar Messages

  • Run query on all connected databases

    Is there a way to run a query across all the databases that you have connections to using a script.

    Fastest way I can think of is changing the connection in the drop-down list (upper right of the worksheet) between runs.
    Regards,
    K.

  • Is it possible to create a rule across 2 models?

    Is it possible to create a rule across 2 models? I added Jack as a creator of an articles in articles model and then I added a row to make creator a subclass of person. So now I'm trying to query across 2 models. I was trying the following query. Give me the grandfather of the author of the article with the title ERNIEX
    SELECT m grandfater, c creator, t title
    FROM TABLE(SDO_RDF_MATCH(
    '(?t :title "ERNIEX") (?m fam:grandParentOf ?c)',
    SDO_RDF_Models('articles2', 'family'),
    SDO_RDF_Rulebases('RDFS', 'family_rb'),
    SDO_RDF_Aliases(SDO_RDF_Alias('','http://purl.org/dc/elements/1.1/'), SDO_RDF_Alias('fam','http://www.example.org/family/')),
    null));
    When I run the query about I get the error
    ORA-20000: We do not have a valid rules index for this Model-Rulebase combination
    So I thought to create a index but I'm not sure how. I tired the following code but I think I'm doing something wrong. Can anyone point me in the right direction. Or for that matter does anyone know of a more extensive tutorial to using the database? Thanks
    BEGIN
    SDO_RDF_INFERENCE.CREATE_RULES_INDEX(
    'rdfs_rix_articles2_faily',
    SDO_RDF_Models('family', 'articles2'),
    SDO_RDF_Rulebases('RDFS','family_rb')
    END;
    Ernest Lim

    You are right, a rules index would have to be created for the rulebases and both the models you use in the query. The example in the rules index creation you have shown at the end of your post does exactly that - creates a rules index for the set of rulebases and models: RDFS, family_rb, family, articles2. Once that rules index is created you should be able to run the query without getting the error.
    Did you get an error while trying to create a rules index using the code shown in your post?
    FYI, a forum for posting semantics questions is at RDF Semantic Graph

  • SPARQL query with OPTIONAL

    Hi,
    When I run a SPARQL query with OPTIONAL in the WHERE clause, I saw a lot of "select 1 from ***" kind of queries got executed. The query runs very slow. I'm running Jena adaptor 2 against Oracle 11.1.0.6. We have about half million triples in the model. The queries we need to run tend to be complex and they run pretty slow. Does Oracle 11.1.0.7 have big query performance improvement over 11.1.0.6? Is there anything that we can do on the application side or on the database side to boost the query performance? Thanks,
    Weihua

    Native database support for OPTIONAL in SEM_MATCH based RDF query has been made available via patch 7600122 on 11.1.0.7. Direct use of SEM_MATCH to query your data from SQL has significant performance benefits.

  • Same the same query against all the schemas

    Hi all,I am a newbie to databases
    I have a requirement where in in need to run the same query against all the schema s in the database.what would be the best way to do it.other than logging into each user and running query.Its a complex query I can't do a direct select  from sys or other even for I will have to change a lot of things.Is there a easier way to do it ??
    Thanks in advance

    990051 wrote:
    Hi all,I am a newbie to databases
    I have a requirement where in in need to run the same query against all the schema s in the database.what would be the best way to do it.other than logging into each user and running query.Its a complex query I can't do a direct select  from sys or other even for I will have to change a lot of things.Is there a easier way to do it ??
    Thanks in advance
    you have a choice between logging into each user & running the SQL or you can log into each user & run the SQL.

  • A script that will query for the last successful backup to tape across all protected datasources

    I've searched trying to locate an existing script for this and come up empty so far but essentially what I am trying to do is have a script I can run that will query for the latest backup to tape that succeeded for each data source across all of the protection
    groups then output that time/date for each to a file.
    I'm extremely new to scripting so I am unsure of how to go about getting started with this so any help would be greatly appreciated!

    this should work
    foreach ($DS in $DSList)
    $RP=$DS | Get-RecoveryPoint | where {$_.Location -eq "Media"} | Sort-Object -Property Backuptime -Descending | select -First 1 | select *
    $Tape=Get-DPMTape -DPMLibrary $Library | where {$_.ID -eq $Rp.RecoverySourceLocations.MediaMapList.MediaId}
    $obj = New-Object -TypeName PSObject
    $obj | Add-Member Noteproperty -Name DatasourceName -value $DS.Name
    $obj | Add-Member Noteproperty -Name Sourcecomputer -value $DS.Computer
    $obj | Add-Member Noteproperty -Name BackupTime -value $RP.BackupTime
    #$obj | Add-Member Noteproperty -Name Location -value $Tape.Location.tostring()
    #$obj | Add-Member Noteproperty -Name Medialabel -value $Tape.Medialabel
    #$obj | Add-Member Noteproperty -Name Barcode -value $Tape.Barcode.Value
    $Array+=$obj
    Seidl Michael | http://www.techguy.at | twitter.com/techguyat |
    facebook.com/techguyat |
    youtube.com/techguyat

  • I need to create 4 A2 boards that print adjacent to one another with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards.Do I use illustrator (C3) or Indesign?

    I need to create 4 @ A2 boards that print adjacent to one another (all landscape format) with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards? Is it best to use Illustrator(CS3) or Indesign?
    Thanks.

    Re: I need to create 4 A2 boards that print adjacent to one another with a photo image running across all 4 boards.How do I set up the pages so I can see the whole composition together , then print the seperate A2 boards.Do I use illustrator (C3) or Indesign
    If possible, please try Indesign CS 4.

  • Fan always running on my HP Pavilion All-in-One 200-5000 (model #2MD0400F1W)

    The fan on my HP Pavilion All-in-One 200-5000 (model #2MD0400F1W) seems to be always running (and it's not quiet). I believe I'm running the latest BIOS and I've already checked to make sure the air vents are clear. I'm not running any memory or processor intensive applications. Any suggestions how to reduce how long and frequently the fan seems to be running? Thanks.

    Hello @jmgoldsmith,
    I understand that you are having issues with the fan always running on your HP Pavilion All-In-One 200-5000 Desktop PC. I would be happy to assist you, but first I would encourage you to post your product number for your computer the number you provided is not a product number (example : HP Pavilion All-In-One 200-5000t CTO Desktop PC has a product number of BN997AV). I am linking an HP Support document below that will show you how to find your product number. As well, if you could indicate which operating system you are using. And whether your operating system is 32-bit or 64-bit as with this and the product number I can provide you with accurate information.
    How Do I Find My Model Number or Product Number?
    Which Windows operating system am I running?
    Is the Windows Version on My Computer 32-bit or 64-bit?
    Please re-post with the requested information and I would be happy to provide you with assistance. Thank you for posting on the HP Forums. Have a great day!
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    Dunidar
    I work on behalf of HP
    Find out a bit more about me by checking out my profile!
    "Customers don’t expect you to be perfect. They do expect you to fix things when they go wrong." ~ Donald Porter

  • Maximum Size of bind variables/model names in a SPARQL query

    I was wondering what the maximum field size is for a bind variable (?'' being used in the subject or object within a triple) in a SPARQL query using the Jena Adapter for Oracle? The reason for this is that I keep getting Oracle exception (ORA-00972: identifier is too long) when executing queries.
    The other question dealt with the max size of the model names? Is there anyway to increase this length by extending certain classes within the Jena Adapter for Oracle?
    Thanks,
    Rahul

    Hi,
    For model names, because we use model names together with some suffixes to create namespace tables, application tables, and indexes, the length
    has to be shorter than 30 bytes - 11 bytes = 19 bytes.
    Note that 30 bytes limit is imposed by Oracle database. You cannot create a table with a name longer than 30 bytes.
    11 bytes is the maximum suffix length imposed by Jena Adapter. We are considering to reduce it to 4 for the next Jena Adapter release.
    For variable names, because we translate SPARQL to SQL queries (and variable name to column alias), there is the same 30 bytes limit.
    Note that there are suffixes for variable names as well. For example, $RDFVID, $RDFLTYP, ... These suffixes are used internally.
    Some simple tests for illustration purpose.
    SQL> create table a23456789012345678901234567890(i int);
    Table created.
    SQL> create table a234567890123456789012345678901(i int);
    create table a234567890123456789012345678901(i int)
    ERROR at line 1:
    ORA-00972: identifier is too long
    -- Assume table X has a column I
    SQL> select i as "v23456789012345678901234567890" from x;
    no rows selected
    SQL> select i as "v234567890123456789012345678901" from x;
    select i as "v234567890123456789012345678901" from x
    ERROR at line 1:
    ORA-00972: identifier is too long
    Hope it helps,
    Zhe Wu

  • If we run a query,what all happens in background/what are phases of query processesing.?

    Hi Friends,
    if we run a query,what all happens in background/what are phases of query processesing.?
    Many thanks
    Shashikala

    It has to go through
    Parsing-on this stage it perform basic check on code (T-SQL,
    Binding(Algebrizer Stage)-on this stage does more parsing and perform query tree,
    Optimize- on this stage take query tree from Binding and parsing and find a better way to return the result that you need so cost might apply here and then
    Execute 
    To know about transaction Log we have to know first how Transaction log file internally works: when you are trying to make change in data as Insert, Update, Delete requests
    from applications using T-SQL or on object explorer, SQL Server will load (load) to the corresponding page data memory where we call this memory area as DATA CACHE.  Then the data in the data cache are changed which is also known as known as DIRTY PAGE.
    Next all changes we made by running query will be recorded in the transaction log file so they called the write-ahead log. At final stage, a process known as CHECK POINT PROCESS will check and write all the transaction has been committed AND completed to your
    hard drive by flushing the page.
    So simply put here are the steps
    Data modification sent by application
    Data pages are located in or read into, cache and modified
    Modification is recorded in transaction log on DISK
    Checkpoint writes committed transactions to database
    I hope this helps a bit in answering your question good luck.

  • Having trouble updating Website Media Query as desktop version across all platforms/devices in .css

    Hi all,
    thank you for taking the time to read this.
    I've been wondering how to update my website to view as a desktop version across al platforms... I am super new at this but have been having great success thanks to everyone in this forum.  I've been making updates to the site and want to keep a desktop version across all platforms...below is what i get when i view it from my phone and would like to see it as a regular pc. Thanks all!
    here is the current .css and link to my site http://www.mauiandsonsretail.com
    /*  Boxed Layout
        .bg-cover {
            background-attachment: fixed;
            background-position: 50% 50%;
            background-size: cover;
            background-repeat: no-repeat;
        body {
      background: url(../images/content/bg_img01.jpg);
      font-family: "Century Gothic", "Arial Narrow", Century, Cambria;
      color: #000000;
      font-size: 12pt;
      font-weight: 100;
      line-height: 1.4;
        #body-wrapper {
      left: 50%;
      margin-left: -500px;
      padding-top: 0;
      padding-bottom: 0;
      width: 980px;
      -webkit-box-shadow: 0 0 4px rgba(0,0,0,.3);
      box-shadow: 0 0 4px rgba(0,0,0,.3);
      overflow-x: hidden;
      padding-left: 25px;
      padding-right: 25px;
    /*  Media Queries
    /* Standard 960 or larger (browsers) */
    @media only screen and (min-width: 960px) {
    /* Smaller than standard 960 (devices and browsers) */
    @media only screen and (max-width: 979px) {
        #body-wrapper {
            margin-left: -404px;
            width: 960px;
            padding: 0 50px;
        .fullwidth {
            margin-right: -50px !important;
            margin-left: 0px !important;
        .fullwidth-padding {
            margin-right: -50px !important;
            margin-left: -50px !important;
            padding-right: 50px !important;
            padding-left: 50px !important;
    /* Tablet Portrait size to standard 960 (devices and browsers) */
    @media only screen and (min-width: 768px) and (max-width: 959px) {
    /* All Mobile Sizes (devices and browser) */
    @media only screen and (max-width: 767px) {
        #body-wrapper {
            margin-left: -250px;
            width: 440px;
            padding: 0 30px;
        .fullwidth {
            margin-right: -30px !important;
            margin-left: -30px !important;
        .fullwidth-padding {
            margin-right: -30px !important;
            margin-left: -30px !important;
            padding-right: 30px !important;
            padding-left: 30px !important;
    /* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
    @media only screen and (min-width: 480px) and (max-width: 767px) {
    /* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */
    @media only screen and (max-width: 479px) {
        #body-wrapper {
            margin-left: -165px;
            width: 280px;
            padding: 0 25px;
        .fullwidth {
            margin-right: -25px !important;
            margin-left: -25px !important;
        .fullwidth-padding {
            margin-right: -25px !important;
            margin-left: -25px !important;
            padding-right: 25px !important;
            padding-left: 25px !important;

    Before you touch one more thing in this site, you need to get up to speed on Responsive Web Design and all that it entails.  That is the bleeding edge trend right now.  Reverting to pixel layouts is not going to improve your site.  It will throw it back into the stone age.  So don't do it.
    Responsive Web Design
    http://coding.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/
    Introduction to CSS Media Queries
    http://www.adobe.com/devnet/dreamweaver/articles/introducing-media-queries.html
    Responsive web sites need responsive menu systems.  Below are some links to follow:
    PVII's Pop-Menu Magic3 (commercial DW extension)
    http://www.projectseven.com/products/menusystems/pmm3/index.htm
    Responsive Iconic
    http://www.dynamicdrive.com/style/csslibrary/item/responsive_iconic_menu/
    Responsive Hybrid
    http://www.dynamicdrive.com/dynamicindex1/responsivehybridmenu/index.html
    jQuery Superfish (desktop)
    http://users.tpg.com.au/j_birch/plugins/superfish/
    jQuery MeanMenu (responsive on mobile)
    http://www.meanthemes.com/plugins/meanmenu/
    Good luck!
    Nancy O.

  • NQSError 14020 When Running Cross-Fact Query

    I keep getting the following error when trying to run a cross-fact query in OBIEE Answers:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 14020] None of the fact tables are compatible with the query request D3.X. (HY000)
    I set up a whole new RPD with only 4 tables, and made sure all the content levels were set up correctly, but I'm still getting the error. I have the following setup:
    Physical
    I have 2 fact tables and three dimensions
    F1 <- D1, D2
    F2 <- D2, D3
    BMM
    I have one fact tables and three dimension tables:
    F <- D1, D2, D3
    I created a dimension higherarchy for each dimension table and kept the two default logical levels --Total and Detail.
    Each dimension table has a single LTS set to the "Detail" level.
    The fact table has two LTS, and the levels are set up as follows:
    F1: D1=Detail, D2=Detail, D3=Total
    F2: D1=Total, D2=Detal, D3=Detail
    Answers
    I'm trying to run the following request in OBIEE Answers: D1.x, D2.x, D3.x
    Could anyone could point me in the right direction?
    - Tim

    Hi Tim,
    In your query, do you just have the dimensions? How about having measure in that report and checking if you still have the same error.
    I see your LTS settings fine (as you have merged the individual facts to one in BMM). Generally, query across dimensions have to go through the fact to resolve the relations and so in here, it has to go through different facts though ;) . Could you post your query so that we can have a look?
    Thank you,
    Dhar

  • Sql query across multiple tables ina database

    I have 3 MS Access tables in database that are linked by keyed fields in the table.  Is there a way to fetch only certain records that match a criteria across all three of these tables using the database connectivity toolset VIs?

    Thanks.  I am trying to mechanize/run an SQL query like this 
    SELECT Code_Type.Code_NUM, Code_Type.Code_Word, Word_Type.Parm_Label, Word_Type.Word_Sequence, Word_Type.Num_Words, Parameter_Label.Parm_Label, Parameter_Label.Parm_Name, Parameter_Label.Num_Bits, Parameter_Label.Num_Bits
    FROM (Code_Type INNER JOIN Word_Type ON Code_Type.Code_Word = Word_Type.Code_Word) INNER JOIN Parameter_Label ON Word_Type.Parm_Label = Parameter_Label.Parm_Label;
    while using the VIs in the database connectivity toolset.  How do I code this using these VIs?  I dont see an example of a straight SQL string like this being able to be put into the VIs.

  • Webpages stop loading after some time across all browsers

    I have come across a problem that 2 of the users that I support have been experiencing recently and I am trying to figure out where to begin.  They will be able to use the internet, access webpages and everything for some time till at one point seemingly randomly all web browser connectivity becomes stuck at the dialog Connecting and eventually times out trying to connect to the host server.  Yet other forms of internet access, like ping and telnet, work just fine at this point.  Basically it seems that all traffic going to ports 80 and 8080 times out and I have pulled the logs where I believe this happened and pasted them here:
    http://pastebin.com/VPSPwyBe
    A temporary fix for this so far is a quick reboot and everything behaves normally for sometime till web access drops and another reboot is required.  This is true across all browsers, IE, Firefox, and Chrome on a MacBook Pro Retina 15" running OSX 10.9.4.  I have tried fresh installs of all the browsers and switching to a different OS X user account and still have the same problem.  I have also tried to flush the DNS using the terminal and that has had no effect.  There are no proxies involved and resetting the wireless adapter produces no results.  Going to keep searching for some other steps to try to fix this and will keep this thread updated.

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
    The login screen appears even if you usually login automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of the test.

  • Script to run a DB query, but have multiple DB servers (for failover) I want to loop through until I find one that is available

    Conceptually I'm not sure the best way to go about this, looking for some guidance.  I'm running a MySQL query and I have the code working against a single MySQL server.  However I want to build some redundancy into the code so if it tries one
    DB and it's not available, it tries the next one.  I have come up with two ways to do this.
    First one is basically an If statement looking at error[0] as a condition.  Tries to connect to the first server and if throws an error, it tries the second and if that fails it exits the code.  This is less scalable as I have to code in connection
    strings for each server.
    Second one is a loop that goes through connection to each DB server I setup in an array until the connection.state = "open", then it should proceed to the rest of the code.
    Foreach ($MySQLHost in $SQLHostArray) {
    $error.clear()
    $ConnectionString = "server=" + $MySQLHost + ";port=3306;uid=" + $MySQLAdminUserName + ";pwd=" + $MySQLAdminPassword + ";database="+$MySQLDatabase
    $Connection.ConnectionString = $ConnectionString
    do {$connection.open()}
    until ( $Connection.state -eq "open" )
    However I don't know how to exit that loop if all servers fail. 
    Which is the best bet for building failover into the script, or is there a better way I haven't thought of yet?

    You could use a counter - 
    $lexit = 0
    $count = ($SQLHostArray.count -1)
    Foreach ($MySQLHost in $SQLHostArray) {
    $lexit++
    $error.clear()
    $ConnectionString = "server=" + $MySQLHost + ";port=3306;uid=" + $MySQLAdminUserName + ";pwd=" + $MySQLAdminPassword + ";database="+$MySQLDatabase
    $Connection.ConnectionString = $ConnectionString
    do {$connection.open()}
    until ( $Connection.state -eq "open" -or $lexit -eq $count)

Maybe you are looking for

  • How to capture userid,date in a custom table while updating a form

    Hi, I have a requirement to insert the userid, the form name and the date on which the record is saved in a custom table while updating a custom form. We are using Form Builder 6.0. I am new to Forms and can anyone help me with these? I would also wa

  • How to play a GP video clip on a PC

    I cant play a GP video clip sent to me on my pc what download do i need and where can i get them

  • Delete from remote location with where clause between the two databases

    I want to delete records from a source database using dblink. The criteria for the delete is a where clause, that looks for the values between a table at source and the remote location. I get an invalid sql statement error. When i do a count(*) inste

  • Why does this keep giving a parse error when trying to use JavaHelp

    I'm trying to get JavaHelp to integrate into my application, but when I call the code below I get the following error; javax.help.HelpSetException: Could not parse Got an IOException (null) Parsing failed for nullthe error is occuring at the line ind

  • PrintOut method Fails

    We have a remote system that uses Crystal Reports XI.  Lately, our application has been crashing apparently due to Crystal.  The most recent change is that we put a laser printer at another remote site that connects to this site.  The connection curr