aspose file tools*
The moose likes Other Application Frameworks and the fly likes DataSource in Spring wiht Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "DataSource in Spring wiht Hibernate" Watch "DataSource in Spring wiht Hibernate" New topic
Author

DataSource in Spring wiht Hibernate

Prav Chau
Ranch Hand

Joined: Jul 17, 2007
Posts: 58
Can anyone send me code snippet for implementing my own spring datasource and using in HibernateDAO class.

Thanks


Prav Chau
SCJP, SCWCD, SCBCD, SCEA, http://pravinchaudhari.blogspot.com/
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

What do you mean your own datasource? Do you want to implement the DataSource interface in a custom datasource class?

Otherwise you just configure it in your xml file using one of Springs DataSource classes. www.springframework.org has the documentation in Core Spring.

Good Luck

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Prav Chau
Ranch Hand

Joined: Jul 17, 2007
Posts: 58
Yes, Basically I want to create custom Datasource which I can pass to Hibernate or JDBC through spring.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Prav Chau wrote:Yes, Basically I want to create custom Datasource which I can pass to Hibernate or JDBC through spring.


OK, I am still confused at what you want.

You plan on doing this???

public class MyCustomDataSource implements DataSource {...}

If so, I must ask why you want to do this? I would never do this, since others have created better DataSource objects than I could ever create.

The only reason why you might do this yourself is if you are creating Spring Framework or creating your own App Server. Otherwise, just use the ones that they created.

But if you do want to do it, then you just create a class that implements the DataSource interface. Then in Spring when you declare your datasource bean, you just have the class attribute point to your class you created. It is just the same as if you used someone else's DataSource class.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DataSource in Spring wiht Hibernate
 
Similar Threads
DataSource managed by JBoss VS DataSource Managed By spring
retrive data from oracle database using struts
Petclinic of Spring2.5.6 with MYSQL and GLASSFISH
JPA-hibernate-spring config
How to connect multiple databases at a time using Hibernate