0

I have two tables, tableone and tabletwo from a MySQL database. Both tables have the same fields, I want to make one script in jsp that copies all data from tableone into tabletwo. I have two sql files that contain databases, tableone.sql and tabletwo.sql.

Can anybody help me with this problem?

JYelton
  • 35,664
  • 27
  • 132
  • 191
Jayesh
  • 3,661
  • 10
  • 46
  • 76
  • It's not different from how you do it in Java. Writing Java code in JSP files instead of normal Java classes doesn't make it a JSP specific problem. – BalusC Nov 05 '11 at 17:47

1 Answers1

2

Don't do this in a JSP. DO this in a Servlet. JSP is used to output HTML markup. Servlets are used to contain Java code executing some logic. Read How to avoid Java code in JSP files?.

You need to

  • create and start a MySQL database. An SQL file doesn't contain a database. It contains SQL instructions that can be used to populate some database.
  • create the schema for your two tables (probably with your SQL files, but I don't know what they contain
  • learn how to use JDBC
  • execute a query which reads every row from table A and insert the data of each row into table B. You'll neeed prepared statements to do that.
Community
  • 1
  • 1
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255