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?

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









Related Tutorials/Questions & Answers:
how to take input table name in jsp to create table in mysql?
how to create database and table using jsp
Advertisements
how to take a backup of a table in sql
How To Create a Table.
how to create a table
Create a Table in Mysql database through SQL Query in JSP
PHP How to Create Table
Java to create table in jsp file that include other jsp file
How we can create a table through procedure ?
SQL Alter Table Name
Impact on change of table name
How to read textfile and create SQL server table ?
Altering a Column name in a table
How to Create Multiplication Table from 1 to 10?
MySQL take backup of a table - example code needed
syntax for create a table
how tohow to create a table with primary key and foreign keyhow to create a table with primary key and foreign key
How to search the table name in MS SQL Database 2005 from application
Create Table in SWT
Create a Table - Java Beginners
how to create a new table for the already existing user in the website
Java Table Create
How do we create new table apart from mapping with existing table ?
How to take input by user using jDialogue and use that input
Shorting Table View By Column Name
how to display data in List Or grid or in table in Jsp
Dynamic table in jsp
MySQL Create Table
Java program to create a frame with 4 fields;name,sreet,city,pin;with suitable table
table
To write a Java program To create a frame with 4 fields;name,street,city,pin;with suitable table
creating instance of table in jsp
alter table create index mysql
How to create an input box?
Using poi hwpf,how to create table in word document. - Java Beginners
display table details when selecting table name in drop down liat
table
Jsp table Pagination
alter table create index mysql
JSP Financial Year Table
How to search the selected item in row table using radia button in JSP?
table?
Table
What is the syntax for a CREATE TABLE statement?
Table
Table
TABLE
how to store data in other table using servlet and jsp
table
Table

Ads