qvanegeren wrote:
I've written some code, but I keep running out of database connections in the middle of my load...
Ok. I hit this too, initially. So I wrote a class that would handle all my database connections, whether Hibernate or MS SQL, or MYSQL.
Connection handling is one of the most common issues I see amongst some of the developers I've worked with through the years, and I try to get them to do this:
1) Create a connection only when you NEED it.
2) ALWAYS make sure to close a connection you've opened, as soon as possible.
With Hibernate, I found that it does what it says, it pools your connections to the database, i.e. the first time you call sessionFactory.openSession() it creates a session, and a connection to the database, when you do the session.close() it doesn't actually remove the connection, but pools it till you eventually sessionFactory.close(), which kills everything.
So with any app, my personal view is:
1) Create your Hibernate SessionFactory at the start (or when your first session is required).
2) create a Session from that ONLY when you need it.
3) As soon as you've loaded/saved, close the session to free up the connection
4) When you're completely done, close your SessionFactory to close all connections.
If none of this helps, I can let you have my database class to look at, and of course, modify to fit your project. :)
And Baliukas, I also have complex XMLs, and process them in batches of up to 60,000 at a time (legacy database files)...having to modify, and check data as it goes. But yes, for mass importing of structured, well formatted, "perfect" data, you can do that completely outside of a Java environment.
-G