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

Ads