-->
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.  [ 3 posts ] 
Author Message
 Post subject: problem connecting to postgresql database
PostPosted: Thu Feb 10, 2005 11:21 am 
Newbie

Joined: Tue Jan 11, 2005 12:52 pm
Posts: 17
hi, im following the tutorial on the hibernate site
http://www.hibernate.org/hib_docs/refer ... erence.pdf

ive followed it letter for letter so far.
i cant see what im going wrong. here are the errors that im getting when i run the code.

log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" net.sf.hibernate.HibernateException: Could not find datasource
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
at net.sf.hibernate.examples.quickstart.HibernateUtility.currentSession(HibernateUtility.java:26)
at net.sf.hibernate.examples.quickstart.CreateCat.main(CreateCat.java:11)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
... 6 more


thanks for any help


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 11:52 am 
Beginner
Beginner

Joined: Tue Jan 11, 2005 5:50 am
Posts: 43
Location: Zurich (Suisse)
Hello

Please post your hibernate.properties or hibernate.cfg.xml file.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 11:57 am 
Newbie

Joined: Tue Jan 11, 2005 12:52 pm
Posts: 17
hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

   <session-factory>

      <property name="connection.datasource">java:comp/env/jdbc/quickstart</property>
      <property name="show_sql">false</property>
      <property name="dialect">net.sf.hibernate.dialect.PostgreSQLDialect</property>

      <!-- Mapping files -->
      <mapping resource="Cat.hbm.xml"/>

   </session-factory>

</hibernate-configuration>



Cat.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

   <class name="net.sf.hibernate.examples.quickstart.Cat" table="CAT">
      <!-- A 32 hex character is our surrogate key. It's automatically
      generated by Hibernate with the UUID pattern. -->
      
      <id name="id" type="string" unsaved-value="null" >
         <column name="CAT_ID" sql-type="char(32)" not-null="true"/>
         <generator class="uuid.hex"/>
      </id>
   
      <!-- A cat has to have a name, but it shouldn' be too long. -->
      <property name="name">
         <column name="NAME" length="16" not-null="true"/>
      </property>

      <property name="sex"/>
      <property name="weight"/>

   </class>

</hibernate-mapping>


do you want my java code as well?

cheers for your help


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.