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 take input table name in jsp to create table in mysql?
how to take a backup of a table in sql
Advertisements
how to create database and table using jsp
how to create a table
How To Create a Table.
PHP How to Create Table
How we can create a table through procedure ?
Create a Table in Mysql database through SQL Query in JSP
SQL Alter Table Name
How to read textfile and create SQL server table ?
How to Create Multiplication Table from 1 to 10?
Altering a Column name in a table
How to search the table name in MS SQL Database 2005 from application
Impact on change of table name
Java to create table in jsp file that include other jsp file
how to create a new table for the already existing user in the website
MySQL take backup of a table - example code needed
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
Create Table in SWT
syntax for create a table
How to take input by user using jDialogue and use that input
How to create an input box?
Shorting Table View By Column Name
Using poi hwpf,how to create table in word document. - Java Beginners
Create a Table - Java Beginners
Java program to create a frame with 4 fields;name,sreet,city,pin;with suitable table
how to display data in List Or grid or in table in Jsp
MySQL Create Table
SQL Alter Table Name
To write a Java program To create a frame with 4 fields;name,street,city,pin;with suitable table

Ads