-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Mixing and matching JDBC properties
PostPosted: Sat Nov 22, 2003 4:16 pm 
Beginner
Beginner

Joined: Tue Sep 30, 2003 4:16 pm
Posts: 33
When letting Hibernate manage my connections, I tried to put some of the connection properties in the hibernate.properties, and then override one of them (the URL in particular) subsequently by doing a Configuration.addProperties().

Things are acting as if somehow this confused hibernate into not providing the other connection properties (I am getting an error message "unknown user") The db is HSQL.

What am I doing wrong?

Pito


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 22, 2003 6:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm...please show the code for what you are doing...i can't deduce it from ya' textual explanation.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 22, 2003 6:32 pm 
Beginner
Beginner

Joined: Tue Sep 30, 2003 4:16 pm
Posts: 33
Here's the code that I am using:
Code:
private SessionHandler(Properties props) throws HibernateException {

    // reads in hibernate.properties implictly for database connection settings
    cfg = new Configuration();

    // attempt to use hibernate.cfg.xml
    try {
      cfg.configure();
    } catch (HibernateException he) {
      logger.info("Can't find \"hibernate.cfg.xml\" in classpath.");
    }

    // add base classes
    cfg
      .addClass(Channel.class)
      .addClass(Item.class)
      .addClass(ItemGuid.class)
      .addClass(ItemEnclosure.class)
      .addClass(ItemSource.class)
      .addClass(Cloud.class)
      .addClass(Category.class)
      .addClass(ChannelGroup.class)
      .addClass(ChannelSubscription.class)
      .addClass(Image.class)
      .addClass(ItemMetadata.class)
      .addClass(TextInput.class);

    // If Properties were supplied then use them as the final override
    if (props != null) cfg.addProperties(props);

    // get session factory
    sessions = cfg.buildSessionFactory();
  }

When I call this with the following:
Code:
   Properties hibernateProps = new Properties();
   hibernateProps.setProperty("hibernate.connection.url", "jdbc:hsqldb:" + dbPath);
   new SessionHandler(hibernateProps);

It acts as if other properties than the URL have been lost, because I get an error message saying "unknown username" referring to the JDBC 'user' property.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 22, 2003 7:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Your code looks fine.

I've followed the execution path, and can't find anything wrong in the hibernate src - The properties for the ConnectionProvider is first used when you call buildSessionFactory().

so, i'll suggest you make a SMALL runnable example that illustrate the error - or even better tries to step through the code (it is opensource ;) and see why the properties ain't respected.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.