Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i have to write a component to read xml files and update already created database table. the problem is the xmls change to have new data and the corresponding database table structure then changes.

but i need a generic solution and one component doing it and do not want to code for specific changing xml and database structure

i do not find any ORM, JDBC technologies/ design patters to achieve this. any suggestions?

Thanks,

share|improve this question
2  
There are libraries for dealing with XML and relational databases, but no one size fits all component that you're imagining. The real answer is an ETL tool. You sound like you want everything to magically work. That never happens. –  duffymo Jun 25 at 19:11
    
Maybe you should have a look at Hibernate and the effect of it's hbm2dll=auto setting. –  blafasel Jun 25 at 19:11
    
thanks, etl tools again needs to be coded for specific database structure.. but wanting something magical is source for real inventions :P –  user3776593 Jun 25 at 19:25
    
hbm2dll looks to be creating the tables automatically but in my case i need to create database structures already since it requires some thorough modeling –  user3776593 Jun 25 at 19:26
add comment

1 Answer

Using Hibernate ... It is possible ( Give it a try )

Hibernate, while executing the code first looks for hibernate.properties file ( remember hibernate.properties should be placed in src folder ).

If it finds 'hibernate.properties' file, it read the content of that file first.So, now you write the DriverClass, URL, Username and password to connect with one database (say MySQl) and then by using saveOrUpdate(); method or by using other methods, update the database

For the second database, make use of configuration file, provide the information DriverClass, URL, Username and password inside hibernate.cfg.xml ( or your own name to the cofiguration file) and make use of cfg.configure(); method to read the cofiguration file.

Let me know, if you have any issues

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.