[jboss-user] [Datasource Configuration] - Error : configuring hibernate.cfg.xml dinamically

Marco Leonardini do-not-reply at jboss.com
Sat Nov 3 20:10:09 EDT 2012


Marco Leonardini [https://community.jboss.org/people/thelostknight] created the discussion

"Error : configuring hibernate.cfg.xml dinamically"

To view the discussion, visit: https://community.jboss.org/message/774495#774495

--------------------------------------------------------------
hello

i have a problem when i try to configure the hibernate.cfg.xml dinamically


this is the HibernateUtil.java (according to the reference book )
              Configuration cfg = new Configuration(
                        .addClass(Entidades.Empresa.class)
                        .addClass(Entidades.Persona.class)
                        .setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/hibernate")
                        .setProperty("hibernate.connection.username", "admin")
                        .setProperty("hibernate.connection.password", "");
            cfg.configure();
            
            sessionFactory = cfg.buildSessionFactory();
 


and this is the hibernate.cfg.xml

<hibernate-configuration>
  <session-factory>
   <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>    
    <property name="hibernate.connection.driver_clapss">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/almacen</property>
    <property name="hibernate.connection.username">xxx</property>
    <property name="hibernate.connection.password">xxx</property>
    <mapping resource="Entidades/Persona.hbm.xml"/>
    <mapping resource="Entidades/Empresa.hbm.xml"/>
    
  </session-factory>
</hibernate-configuration>



you can see that in the xml the database is almacen but in the .java im changing it to hibernate. the problem occurs when i try to change the username and password but the java doesnt change those values
 the error i got is:
you can see it doesnt change de the username 
INFO: using driver: null at URL: jdbc:mysql://localhost:3306/hibernate
INFO: connection properties: {user=xxx, password=****, driver_clapss=com.mysql.jdbc.Driver}
WARNING: Could not obtain connection metadata
java.sql.SQLException: Access denied for user 'xxx'@'localhost' (using password: YES)



please help me i want to configure in a dinamically way (i need it) i dont know where is the error

thanks in advance

Leo
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/774495#774495]

Start a new discussion in Datasource Configuration at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121103/c7de3224/attachment-0001.html 


More information about the jboss-user mailing list