Skip to search.
jena-dev · Jena Users

Group Information

  • Members: 2057
  • Category: Software
  • Founded: Sep 19, 2001
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

  Messages Help
Advanced
Problem with creating and accessing databases with MySQL!   Message List  
Reply Message #20320 of 48263 |
Re: Problem with creating and accessing databases with MySQL!

Hi, Richard
I have solved the problem! Everything is working well now.
Thank you so much for your help! I am so happy!!!!(^-^)
Ly ,

--- In jena-dev@yahoogroups.com, Richard Cyganiak <richard@c...> wrote:
>
> Hi Ly,
>
> On 14 Jan 2006, at 10:14, bichly81 wrote:
>
> > Hi,
> > I am trying to save model to MySQL and access it. First, I create an
> > model "m" in RDF, make a connection to mySQL and create model
> > "model".Then set model=m and print it out to check.
>
> Variables in Java are references to objects. The effect of "=" is
> that after the assignment, the variable on the left side refers to
> the result of the right side. Assignment with "=" can never do
> anything "interesting" in Java, like inserting something into a
> database. Assignment only makes a variable point to another object.
>
> So before "model = m", you have this:
>
> m refers to your in-memory model object.
> model refers to your database model object.
>
> After "model = m":
>
> m refers to your in-memory model object.
> model also refers to the in-memory model object.
> No variable refers to the database model object any more! It'll get
> garbage collected. That's how Java works.
>
> So, when you print out model, you get the expected result, but you're
> actually printing the in-memory model, and not the database model!
>
> Apologies if this is confusing!
>
> I think what you tried to do is to *add* all the statements from the
> in-memory model to the database model. You can do it like this:
>
> model.add(m);
>
> After this, model of course still refers to the database model, but
> the "add" method copies all statements from the argument into the
> database model.
>
> (No, "model = model + m" won't work ;-)
>
> Hope that helps,
> Richard
>
>
> >
> > Class.forName(DRIVER);
> > IDBConnection conn = new DBConnection(M_DB_URL, M_DB_USER,
> > M_DB_PASSWD, M_DB);
> > ModelMaker maker = ModelFactory.createModelRDBMaker(conn);
> > model = maker.createModel(modelName);
> > model=m;
> > model.write( System.out ,"RDF/XML-ABBREV");
> > conn.close();
> >
> >
> > At this point,everything seems going well.The output is right with a
> > long RDF file.
> >
> > But then when I make a new connection and access the the databases
> > to access the model with
> >
> > model = maker.openModel(modelName);
> > model.write( System.out ,"RDF/XML-ABBREV");
> >
> > I got the result with just
> >
> > <rdf:RDF
> > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
> > </rdf:RDF>
> >
> > What happened to MySQL database? What should I do to solve te
> > problem?
> >
> > Thank you,
> > Ly,
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>







Sat Jan 14, 2006 3:37 pm

bichly81
Offline Offline
Send Email Send Email

Message #20320 of 48263 |
Expand Messages Author Sort by Date

Hi, I am trying to save model to MySQL and access it. First, I create an model "m" in RDF, make a connection to mySQL and create model "model".Then set...
bichly81 Offline Send Email Jan 14, 2006
9:14 am

Hi Ly, ... Variables in Java are references to objects. The effect of "=" is that after the assignment, the variable on the left side refers to the result of...
Richard Cyganiak
cygri Offline Send Email
Jan 14, 2006
2:11 pm

Hi, Richard I have solved the problem! Everything is working well now. Thank you so much for your help! I am so happy!!!!(^-^) Ly ,...
bichly81 Offline Send Email Jan 14, 2006
3:40 pm
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help