how to copy database as it is to a new database by java code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Abdulrhman
    New Member
    • Aug 2010
    • 2

    how to copy database as it is to a new database by java code

    Hi

    I want to ask about how to copy database as it is to a new database by Java code.

    I mean to copy the database all at once by one code, not table by table.

    Thanks in advance.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    what database are you using?

    Comment

    • Abdulrhman
      New Member
      • Aug 2010
      • 2

      #3
      Thank you for replying

      I use Microsoft SQL Server 2008

      Thanks

      Comment

      • chaarmann
        Recognized Expert Contributor
        • Nov 2007
        • 785

        #4
        So do you want to copy all the binary files? You can do that easily with Explorer. (Or you can use FileUtils from Apache Commons to copy files with Java). I am not sure if this works with Microsoft SQl-server, but for MySql copying the database table files to another database worked fine for me.
        Another way is to make a database-dump as sql-statements from the old database and then run them on your new database. This way the old and new database need not to be the same.
        The other way is reading the data table by table through JDBC (or Hibernate) and copy them, only then you need java code to do so. But this way you said you don't want.

        Comment

        Working...