JDBC_CreateDropTable1
Create Insert Drop  MySQL Table: Image below presents, before creating a new table:
  •  String sql1 = "create table visitor1(" + "id int," + "fname varchar(30)," + "lname varchar(30)," + "age int(2))";
  • String sql2= "drop table if exists visitor1;";
  • String sql3 ="Select * from visitor1";
  • String str1 ="INSERT INTO visitor1 values(101,'John', 'Doe', 40)";
    String str2 ="INSERT INTO visitor1 values (102,'Peter', 'Pan', 44)";
     
  •  //create table visitor1
    st = c.createStatement();
    st.execute(sql1);
     
  • Code : JDBC_CreateDropTable1.txt
Code Snippet:: ( Also see the same, using function );

processing result set

Table created :: viewing with MySQL WorkBench
Result:

Code : create table visitor1 ("+" "id int," + "fname varchar(30)," + "lname varchar(30)," + "age int(2))"; INSERT INTO visitor1 values (101,'John', 'Doe', 40); INSERT INTO  visitor1 values (102,'Peter', 'Pan', 44);