how to take input table name in jsp to create table in mysql?

Ads
 

how to take input table name in jsp to create table in mysql?

how to take input table name in jsp to create table in mysql?

View Answers

November 19, 2010 at 10:55 AM

Hello Friend,

Try the following code:

<%@page import="java.sql.*"%>
<form method="post">
Enter Table Name:<input type="text" name="table"><input type="submit" value="Create Table">
</form>
<%
String tab=request.getParameter("table");
try{
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "root", "root");
        Statement st = con.createStatement();
        String table = "CREATE TABLE "+tab+"(id integer, name varchar(100), address varchar(100))";
        System.out.println(table);
        st.executeUpdate(table);
        out.println("Table is created successfully!");
      }
      catch (Exception e){
      e.printStackTrace();
    }
    %>

Thanks

Ads









Related Tutorials/Questions & Answers:
how to create database and table using jsp
how to take a backup of a table in sql
Advertisements
how to create a table
How To Create a Table.
Java to create table in jsp file that include other jsp file
How to read textfile and create SQL server table ?
How to Create Multiplication Table from 1 to 10?
SQL Alter Table Name
how to create a new table for the already existing user in the website
How to search the table name in MS SQL Database 2005 from application
How do we create new table apart from mapping with existing table ?
how tohow to create a table with primary key and foreign keyhow to create a table with primary key and foreign key
syntax for create a table
Create Table in SWT
Impact on change of table name
how to display data in List Or grid or in table in Jsp
MySQL take backup of a table - example code needed
Shorting Table View By Column Name
How to search the selected item in row table using radia button in JSP?
How to get table row contents into next jsp page
how to load a table of data from oracle, to a jsp page using hashmap.
how to store data in other table using servlet and jsp
MySQL Create Table
Java program to create a frame with 4 fields;name,sreet,city,pin;with suitable table
How to take input by user using jDialogue and use that input
how to display data from mysql table in text box using jsp??
creating instance of table in jsp
alter table create index mysql
Dynamic table in jsp
How to add a column with checkboxes for each record in my table in JSP
SQL Alter Table Name

Ads