1

I am having a result set for a particular MySQL Query in Java. What I want to do is to generate the possible query for the generated result set so I can execute those statement to some other database with few modification in the statement. Is there any way i can do that in java?

vineetv2821993
  • 927
  • 12
  • 25
  • http://www.convertcsv.com/csv-to-sql.htm Go to this link and you will know what similar I am trying to do which someone already achieved. And please dont down vote before yourself dont know the answer. – vineetv2821993 Jun 23 '14 at 09:11
  • Oh, you are talking about INSERT statements for data migration. When you said "query", I thought you meant a SELECT statement. That makes more sense indeed. (And I did not downvote) – Thilo Jun 23 '14 at 09:13
  • 1
    Sorry for being rude, but i am struck in this situation from weeks. if you get what i want you can edit this post :) – vineetv2821993 Jun 23 '14 at 09:15
  • 1
    @vineetv2821993 I downvoted because it wasn't entirely clear what you were asking. If you edit the question to make it clear, as you did in your first comment, I'll revert it. – Anthony Grist Jun 23 '14 at 09:18
  • thanks @AnthonyGrist :) , actually my actual problem is here http://stackoverflow.com/questions/24351849/java-mysql-to-hive-import-where-mysql-running-on-windows-and-hive-running-on-c . I am just trying some alternative way to solve it. please help me out :( – vineetv2821993 Jun 23 '14 at 09:20

1 Answers1

1

After reading the comments and your question, it seems that you are trying to create insert queries based on the resultset values that you got and use them for data migration

To create insert statements first you need to have the column types of the table that you are trying to insert into the table as well as the resultset pulled from.

The former you can be easily predicted by viewing the table schema and the latter can be got by functiongetColumnType() using ResultsetMetaData object

So here you go,

  1. Get the columns type along with the resultset data from source database.
  2. Convert the resultset data to the datatype that is equivalent on the database that you are going to migrate.
  3. Create insert statements using the converted values and insert them in the destination database.

This is just a small overview of how the migration process can be achieved. Hope this will provide a basic understanding on how the task can be done.

BDRSuite
  • 1,594
  • 1
  • 10
  • 15