Search the web
Sign In
New User? Sign Up
jena-dev · Jena Developers
? 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.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Problem with creating and accessing databases with MySQL!   Message List  
Reply | Forward Message #20320 of 42066 |
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
Online Now Online Now
Send Email Send Email

Forward
Message #20320 of 42066 |
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
Online Now 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
Online Now Send Email
Jan 14, 2006
3:40 pm
Advanced

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