SPARQL endpointへの問い合わせ2008-12-25 09:54:02

DBPediaなど公開されているSPARQL endpointが増えている.
これらのendpointに対して問い合わせ処理をJenaで行う場合はQueryExecutionFactoryクラスのsparqlServiceメソッドを利用する
サンプルコードは以下の通り.

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;

public class UsingSparqlEndpointSample {

    public static void main(String[] args) {
        new UsingSparqlEndpointSample ();
    }

    public UsingSparqlEndpointSample () {
        // query
        String sparql = "select * where {?rc  ?x .} limit 10";
        // sparql endpoint's url
        String service = "http://dbpedia.org/sparql";
        
        Query query = QueryFactory.create(sparql, "",
                Syntax.syntaxSPARQL);
        
        QueryExecution queryExe = QueryExecutionFactory
                .sparqlService(service, query);
        
        ResultSet res =   queryExe.execSelect();
        
        while(res.hasNext()) {
            QuerySolution sol = res.nextSolution();
            System.out.println(sol.get("rc"));
            System.out.println(sol.get("x"));
        }
    }
}
ちなみに関係データベースを使った場合は以下のようになる.
import java.sql.SQLException;
import com.hp.hpl.jena.db.DBConnection;
import com.hp.hpl.jena.query.DataSource;
import com.hp.hpl.jena.query.DatasetFactory;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.ModelMaker;

public class UsingRDBSample {

    public static void main(String[] args) {
        new UsingRDBSample();
    }

    public UsingRDBSample() {
        try {
            String sparql = "select * where {?rc  ?x .} limit 10";

            Class.forName("com.mysql.jdbc.Driver");
           
            DBConnection conn = new DBConnection(
"jdbc:mysql://localhost/test?useUnicode=true&
characterEncoding=UTF-8",
 "user", "password", "MySQL");
            ModelMaker maker = ModelFactory.createModelRDBMaker(conn);
            Model model = maker.openModel("modelName");
            
            Query query = QueryFactory.create(sparql, "",
                    Syntax.syntaxSPARQL);
           
            DataSource ds = DatasetFactory.create(model);
            QueryExecution queryExe = QueryExecutionFactory
                    .create(query, ds);
            
            ResultSet res =   queryExe.execSelect();
            
            while(res.hasNext()) {
                QuerySolution sol = res.nextSolution();
                System.out.println(sol.get("rc"));
                System.out.println(sol.get("x"));
            }
            
            conn.close();
            
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
使う機会はこっちのほうが多いかも.

コメント

_ Orthotic Insoles ― 2015-06-21 03:51:04

I every time emailed this webpage post page to all my contacts, as if like to read it after that my links will too.

_ Arch Support Insoles ― 2015-06-21 17:36:23

I visited many web sites except the audio feature for audio songs present at this web site is truly marvelous.

_ hallux valgus treatment ― 2015-06-28 18:14:22

If some one wants to be updated with newest technologies then he must be visit this web page and be up to date everyday.

_ Look Taller ― 2015-06-29 15:53:10

I every time spent my half an hour to read this weblog's articles everyday along with a mug of coffee.

_ Arch Support Insoles ― 2015-07-01 05:31:49

I'm really loving the theme/design of your website. Do you ever run into any web browser compatibility issues? A small number of my blog readers have complained about my blog not working correctly in Explorer but looks great in Firefox. Do you have any solutions to help fix this issue?

_ Ball Of Foot Pain ― 2015-07-01 16:06:01

Hi there, i read your blog from time to time and i own a similar one and i was just curious if you get a lot of spam comments? If so how do you protect against it, any plugin or anything you can recommend? I get so much lately it's driving me mad so any assistance is very much appreciated.

_ Foot Pain causes ― 2015-07-02 06:32:08

It's appropriate time to make some plans for the long run and it's time to be happy. I've read this put up and if I may I wish to recommend you few fascinating things or advice. Maybe you can write next articles regarding this article. I desire to read even more issues about it!

_ Insoles For Height ― 2015-07-05 01:01:01

Hi! I could have sworn I've been to this website before but after browsing through some of the post I realized it's new to me. Anyhow, I'm definitely delighted I found it and I'll be bookmarking and checking back frequently!

_ Foot Pain ― 2015-07-05 14:37:52

I always spent my half an hour to read this weblog's articles all the time along with a mug of coffee.

_ Growth Plus ― 2015-08-22 03:15:46

Please let me know if you're looking for a article writer for your weblog. You have some really great posts and I feel I would be a good asset. If you ever want to take some of the load off, I'd love to write some material for your blog in exchange for a link back to mine. Please send me an email if interested. Regards!

_ Insoles For Height ― 2015-08-25 02:28:31

This post offers clear idea in support of the new people of blogging, that actually how to do blogging.

_ quest bars ― 2015-08-30 19:44:54

Thank you for some other great post. The place else could anyone get that kind of information in such an ideal means of writing? I've a presentation subsequent week, and I am on the search for such info.

_ quest bars ― 2015-08-31 18:18:34

Hi there, its fastidious post about media print, we all understand media is a impressive source of data.

_ quest bars ― 2015-09-01 03:55:27

Hey There. I discovered your weblog the usage of msn. That is a really well written article. I'll make sure to bookmark it and come back to read more of your useful information. Thank you for the post. I will definitely return.

_ quest bars ― 2015-09-02 00:48:43

What's up to every one, for the reason that I am truly eager of reading this website's post to be updated daily. It includes pleasant stuff.

_ minecraft games ― 2015-09-11 00:19:49

It's actually very complicated in this busy life to listen news on Television, so I just use web for that reason, and get the latest news.

_ plenty of fish dating site of free dating ― 2015-09-22 17:18:33

I do accept as true with all the concepts you have presented for your post. They are really convincing and can certainly work. Still, the posts are very quick for starters. Could you please extend them a bit from next time? Thanks for the post.

_ Plenty Of Fish Dating Site Of Free Dating ― 2015-10-07 12:56:31

I could not resist commenting. Well written!

_ plenty of fish dating site of free dating ― 2015-10-15 22:57:55

I'll right away clutch your rss as I can not in finding your e-mail subscription hyperlink or newsletter service. Do you have any? Kindly let me realize in order that I may just subscribe. Thanks.

_ match.com free trial no credit card ― 2015-10-30 09:16:51

My relatives always say that I am killing my time here
at web, but I know I am getting know-how every day by reading
thes good posts.

_ forskolin 250 mg ― 2015-11-04 08:16:12

Hi there! I know this is kinda off topic however I'd figured I'd ask.

Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa?
My website addresses a lot of the same topics as yours and I believe we could greatly benefit from each other.
If you're interested feel free to shoot me an email.

I look forward to hearing from you! Great blog by the way!

_ plenty of fish dating site of free dating ― 2015-11-06 05:53:31

I was suggested this blog by my cousin. I'm not sure whether
this post is written by him as nobody else know such detailed about
my problem. You're incredible! Thanks!

_ kroger feedback survey ― 2015-11-12 15:11:39

This is a topic which is near to my heart... Take care!

Where are your contact details though?

_ krogerfeedback.com ― 2015-12-05 13:45:39

Yes! Finally something about kroger.

_ krogerfeedback.com ― 2015-12-09 22:33:32

Hello colleagues, fastidious article and nice urging commented at this place, I am genuinely enjoying by these.

_ krogerfeedback.com ― 2015-12-19 21:25:06

Magnificent items from you, man. I have have in mind your stuff
previous to and you're just extremely magnificent.
I actually like what you've received here, certainly like what you're saying and the best way
during which you are saying it. You're making it entertaining and you continue to care for
to keep it smart. I cant wait to read far
more from you. This is really a terrific site.

_ www.krogerfeedback.com ― 2015-12-19 22:22:07

Hello, this weekend is fastidious designed for me, for the reason that this occasion i am reading this fantastic educational piece of writing
here at my house.

_ quest bars ― 2016-02-09 05:44:18

Wonderful work! That is the kind of info that should be shared
across the web. Shame on Google for no longer positioning this submit
higher! Come on over and discuss with my site .
Thank you =)

_ quest bars ― 2016-02-09 16:11:44

I was recommended this web site by means of my cousin. I'm not certain whether this
post is written by way of him as nobody else recognize such unique approximately my problem.
You are amazing! Thanks!

_ quest bars ― 2016-02-10 05:22:47

Informative article, exactly what I wanted to find.

_ best value ip camera ― 2016-02-25 06:32:28

We have Sales team sent to support our sales with Apple, Amazon and Best Buy.
Yes, ponying up a lots of money over a security camera which is just not proficient enough to present clear night vision may
well not be a great option. For instance, in the event you record someone's telephone conversation without their knowledge, it's illegal.



simplehuman, maker of kitchen and bath tools, offers trash
cans which are high-end with patented sensor technology -- trash cans with sensor technology or 'smart trash
cans. A weighbridge is equipped using a host of innovative functionality including camera plate recognition, surveillance cameras, traffic barriers, traffic lights etc.

_ cctv camera only ― 2016-02-26 03:31:24

Do you wish the CCTV system for being fitted using a professional CCTV Installation company or will
you feel you may install a CCTV system yourself.

It is completely feasible for that you be captured leaving your house from the morning about the school run and going to operate.

Cctv 4 With this, the vigorous growth from the IP video surveillance camera market is additionally benefiting
the makers, vendors and service providers inside market globally.


Article Source: Reiner is often a business owner and professional blogger that enjoys writing on subject matter in connection with lifestyle, diy, security etc.
They are found in locations like prisons, educational centers, train stations, airports, ATMs
etc.

_ radio shack alarms ― 2016-02-26 19:04:34

Home security systems in New York are routine, numerous individuals reducing their likelihood of burglary and theft a toronto injury lawyer security systems put of
their houses. The best feature with the viper car
wireless home alarm is the handheld remote control.
Home alarm equipment Besides, another big advantage could be the
home insurance agencies also favor such homes by providing by having an alarming 5-20% discount every year.


Regardless of your house's location and the value of their contents, it stands to get from having an invisible burglar alarm.
However, it's not at all times possessions a thief is
after, they could have other serious violent crimes planned, another
excuse not to leave your own home and family vulnerable.

_ promptly ― 2016-02-26 19:05:17

One person said they didn't require a vibrator because 'it's not warm also it doesn't hug
me. Electro Magnetic frequency, simply put, may be the radiation that is certainly emanated to us from the many electrical tools we use with a daily basis.
Best cordless tools It's also cordless, so it'll suit any user,
particularly one with a Windows Media Center equipped PC.


Check these safety devices frequently to produce
sure these are secure and properly installed and maintained.
If, however, as much as possible don't look at so well, re-take away the rear cover to ensure the brushes are fully contacting the armature and that
these are oriented properly.

_ source ― 2016-02-27 06:04:33

This is the only way to be able to discover the GPS that
just has features you need and no extras. Some of the newer Garmins
lack the fuse or perhaps the hard wire kit.

Specifically created for use in covered vehicles (cars, vans along with
the like), the Garmin nuvi range is recognized for its ease of usage and clarity of display.
The unit also supports the Garmin topographical maps to assist
you to approach your hunts. Best deals on garmin gps watches
Because there are no obvious signs that the unit is charging, many users will wonder if their GPS is really charging.

_ noob gamer try minecraft Free ― 2016-02-28 13:29:38

And Minecraft Multiplayer command List and multiplayer
server will show. 4J Studios is now working on Title Update 14 for Minecraft that may introduce Adventure Mode to
the console versions in the popular block building title.xt% minecraft skins creator

And Minecraft Multiplayer command List and multiplayer server will show.
4J Studios is now working on Title Update 14 for Minecraft
that may introduce Adventure Mode to the console versions in the popular block
building title.xt%

_ regards ― 2016-02-28 17:15:26

Often a retail establishment will likely be interested in a very CCTV camcorder system which allows the owner as well as the staff to
monitor whether any thefts or other incidents took place.

These days, buying appliances like CCTV camera, electric showers, extractor fans etc.
Cctv 16 channel dvr While we utilized to use a Video
Tape to record movies, DVR works using the help of a
hard disk recorder (HDR).

So you'll find high chances that you will get them just
due to the pressure of a salesman or perhaps a salesgirl
who's trying to sell CCTV to you personally when you are in need for merely a thief alarm.
CCTV42 is focused on providing and advising you about
the correct CCTV camera systems they believe may benefit you or perhaps your company the
most.

_ security camera now ― 2016-02-28 19:25:53

The summer season can make wearing a fancy dress a wonderful idea for a lot of reasons and a number of of them will probably be discussed on this write-up.
This can confuse the internal mechanism that automatically switches camera modes and render a disorganized video.
Security cameras best rated Wait about a short period, the digital camera will reboot, then unplug the network
cable.

Modern night vision cameras record in monochrome at night and several will record
color within the day time, while infrared cameras
can never set you up even during complete darkness.
This has propelled many technical terms related to every device like.

_ all nerf guns ever made list best ― 2016-02-29 11:30:07

Nerf bars and running boards: There is often a selection of Nerf bars, running boards and side tubes as well.
They look the same as an average dog toy, but they do not contain stuffing,
thus dogs tend not to have the need to tear the toy apart also it will last
longer. Nerf all Indeed, they have also created a significant influence in the world
of toys.

From some point of view, the Unholy Blight change looks like a nerf,
but for many situations it is actually a buff. Last but not least, we should choose toys avoiding sharp edges or points.

_ Brand wallet copy my ― 2016-02-29 23:49:01

Famous faces for example Cameron Diaz and Maria Sharapova all wear
TAG Heuer. The Luminox Watch Company is amazing example products hard work,
dedication, inside them for hours a product the U.
Clock copy All globally, everyone is making small changes on their daily lives hoping saving the entire world
we hold so dear.

Chic, luxurious, well-crafted and high-quality, Rolex watches make to the perfect gift for any circumstance, and therefore are
always guaranteed to stun. Android Wear allows you to
reply to texts, emails, and instant messages by voice.

_ how many oz of rice In a cup ― 2016-03-02 20:52:53

Our body needs fat, and it is useful for the body in multible
ways. They are worth the money and a creative addition to any meal or on the go snack.
1 cup butter in grams

_ hitach tools ― 2016-03-03 07:54:35

The body, being a recipient, is vulnerable on the impacts of ionizing radiation. Both are advantages with only one spare battery, will handle more than what it had been made
for. Tools cordless drill The toys include shapes and animals that are soft to touch and moving in the clockwise direction when started up.


Examples of possible clients include Fortune 50 publishing companies
and retailers, roadside assistance services and in addition foreign-based online retailers.
The option of countless user-friendly features at affordable
rates attracts more and more users towards the unit.

_ cups of rice in a pound ― 2016-03-03 08:25:35

Size The net weight of the standard sized can of Green Giant Whole Kernel Sweet Corn is 15.
How about a few slices of turkey or ham or some string cheese.

How many grams in a cup of white sugar

_ female rca to hdmi interest ― 2016-03-04 13:45:13

THE FINAL WORD: The Marantz UD9004 carries a price listing of $5999.

Units tend to possess higher wattage requirements as
being the screen increases. Coax cable to hdmi converter walmart So maybe it is possible to go with out a new X-box 360 but a Play - Station 3could be described as
a 'necessity' to get a brilliant new Flat Screen setup.

Article Source: Paine writes for The Tech FAQ and could be the author of articles including HDMI, HDMI Cable, and HDMI Optical Switch.
The difference is the fact that these cables are
red, green, and blue simply carry video.

_ therere ― 2016-03-05 00:00:36

But, once we walked through the door from the Toddington Northbound Moto service area,
I was amazed to find out a big sign advertising "Free Wi-Fi at all Moto Locations".
Obviously, there was enough interference with electrical and AC ducts,
etc he had no signal.

Today, however, cannot spend fabulous sums to get the owner from the phone with impressive
features. Share your phone's Internet connection using your
other Wi-Fi enabled devices with these great Android tethering apps on your phone.
Wifi booster costco Skype is usually used on a PC, but there are phones designed for use having a Skype account
that permit you to call Skype users just as though you were
using a landline or perhaps a cell phone.

_ foam bed rail ― 2016-03-05 00:34:38

Although they could be great things to grace your personal bedroom,
they could be somewhat larger than ordinary bedrooms, thus trying out
a whole lot more space. Although they could be great
things to grace your personal bedroom, they could be somewhat larger
than ordinary bedrooms, thus trying out a whole lot more space.
Protective bed rails Although they could be great things to grace
your personal bedroom, they could be somewhat larger than ordinary bedrooms, thus
trying out a whole lot more space.

Although they could be great things to grace your personal
bedroom, they could be somewhat larger than ordinary bedrooms, thus trying out a whole lot more space.
Although they could be great things to grace your personal bedroom, they could be
somewhat larger than ordinary bedrooms, thus trying out a whole lot more
space.

_ www.smahu.com ― 2016-03-05 03:58:09

Cheryl Cole helps Joe Mc - Elderry land new record
deal. To complete your total look you can choose a pair of Balenciaga shoes.
Gossip magazine wordpress theme What that
means to me now is that she was communicating to us that she didn't have to decide then, what here future life would be like or what she would do with her life.


If you don`t have a phone number there are a few options for
you. Online gossip girl season 5 episode 21 Premiere of Lost season 6 has given birth to number of questions, which are bubbling in the minds of its followers.

These gossip usually contain the personal lives of the celebrities such as their relationship,
family, products they use or brands they prefer, shopping they do etc.

_ Whirlpool Cabrio Dryer Problems ― 2016-03-05 04:24:10

Spray over the clothing and skin, avoiding the facial skin altogether.
Whirlpool cabrio gas dryer problems A wise purchase always starts using the
exact familiarity with what one wants.

If you happen to be searching to get a gas dryer that will provide you with
absolute best in drying cycles and technologies, then you will need to
take a look with the following product. What I found were a large amount of complicated instructions for
diagnosing the issue.

_ flower photos hd ― 2016-03-05 05:32:20

A special message might be typed directly for the border to increase personalize the image frame.
These clouds are the perfect medium to consider pictures as you will find no shadows over the flowers.
Flower lipstick swatches We would be the only design utility that enables
you to download the print-ready images.

You can wish all your family members on all special times of
their life with this Bangalore flower delivery service. With escalating demand
for shopping flowers and flower gifts online, do you need to utilize this market demand and serve it.

※コメントの受付件数を超えているため、この記事にコメントすることができません。

トラックバック

このエントリのトラックバックURL: http://mhrz.asablo.jp/blog/2008/12/25/4026330/tb