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.  [ 5 posts ] 
Author Message
 Post subject: help connect to mysql 5.0.37 with c3po
PostPosted: Tue Feb 26, 2008 10:20 pm 
Newbie

Joined: Mon Feb 25, 2008 5:55 pm
Posts: 2
Location: Ecuador
Hello friends of the forum is jorge my name and I come from the equator, I am using hibernate 3.2.5, I have been doing both desktop applications such as Web smoothly thanks to the reference, I would like to know if I can help connect to mysql 5.0.37 with c3po, which is what I need to call and file in my hibernate.cfg.xml connection? For a desktop application, ie not need a web server, but of course want to know how to start the session with a different user and password every time I connect to the database ...

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:data/tutorial</property>
<property name="connection.username">sa</property> ****I hope that this data will change every time I go to start a new session ...
<property name="connection.password"></property> ****I hope that this data will change every time I go to start a new session ...
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="Event.hbm.xml"/>
</session-factory>
</hibernate-configuration>

this is posible? please help me, and thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 10:58 am 
Beginner
Beginner

Joined: Thu Aug 17, 2006 12:44 pm
Posts: 22
Location: Ohio
Remove all database connection parameters from your hibernate config file. Put a file called hibernate.properties in your classpath. You can then put your connection and cp30 information there.

Example:
Code:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/mysql_db
hibernate.connection.username=root
hibernate.connection.password=
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=300
hibernate.c3p0.max_statements=50
hibernate.c3p0.idle_test_period=3000


Hope this helps.

Mike.


Top
 Profile  
 
 Post subject: who send this value, from my aplication?
PostPosted: Mon Mar 03, 2008 4:18 pm 
Newbie

Joined: Mon Feb 25, 2008 5:55 pm
Posts: 2
Location: Ecuador
Thank you for your help, what I want to know is whether it is possible to send the user and password connection, as parameters, or are statics to started SessionFactory?

mangelo wrote:
Remove all database connection parameters from your hibernate config file. Put a file called hibernate.properties in your classpath. You can then put your connection and cp30 information there.

Example:
Code:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/mysql_db
hibernate.connection.username=root <-- who send this value, from my aplication? ##
hibernate.connection.password=        <-- who send this value, from my aplication? ##
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=300
hibernate.c3p0.max_statements=50
hibernate.c3p0.idle_test_period=3000


Hope this helps.

Mike.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 4:54 pm 
Beginner
Beginner

Joined: Thu Aug 17, 2006 12:44 pm
Posts: 22
Location: Ohio
Those values are static. The c3p0 cache will create a bunch of connections and hold them in a pool. You don't ask the user for a username and password for your database.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 03, 2008 4:55 pm 
Beginner
Beginner

Joined: Thu Aug 17, 2006 12:44 pm
Posts: 22
Location: Ohio
Those values are static. The c3p0 cache will create a bunch of connections and hold them in a pool. You don't ask the user for a username and password for your database.


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