how to create database and table using jsp

how to create database and table using jsp

hi frnds...., i want to create database and table in mysql using jsp.... i have an registration form(name,sex,address,phone and so on ... ) i want to create individual table in mysql for each user to store their details.. so pls help me how to create individual table using jsp code... the table name should be the name of the person in the registration form... pls its very urgent frnds.. i have tried with many code and its almost looking correct but its not working...

View Answers

August 23, 2012 at 5:39 PM

Here is a jsp code that create table into database according to the name entered by the user.

1)form.jsp:

<form name="form" method="post" action="table.jsp">
    <pre>
    Enter Name:    <input type="text" name="name" size="30"><br>
    Enter Gender : <input type="text" name="gender" size="30"><br>
    Enter Address: <input type="text" name="address" size="30"><br>
    Enter Phone :  <input type="text" name="phone" size="30"><br>

    <input type="submit" name="Submit" value="Submit">
    </pre>
    </form>

2)table.jsp:

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %> 
<html>
    <head>
        <title>display data from the table using jsp</title>
    </head>
    <body>
        <%
            String name=request.getParameter("name");
            String connectionURL = "jdbc:mysql://localhost:3306/test";
            Connection connection = null;
            Statement statement = null;
            try {
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                connection = DriverManager.getConnection(connectionURL, "root", "root");
                statement = connection.createStatement();
                String QueryString = "create table "+name+"(id int not null auto_increment,name " +
                        "varchar(25),gender varchar(20),address varchar(50),phone varchar(20), primary key(id));";
                statement.executeUpdate(QueryString);
                        %> 
                        Table of specified name is created successfully.
            <%      }
                        catch (Exception ex) {} 
                        finally {

                statement.close();
                connection.close();
            }
            %>
    </body>
</html>

August 23, 2012 at 5:59 PM

thank u for the code... its working good...


August 23, 2012 at 6:21 PM

Am having problem with the below code....

<link href="styles.css" rel="stylesheet" type="text/css"/>     
<%@page import="java.sql.*"%>
<%@ page import="java.io.*" %>Â 
<%
             String groupname = request.getParameter("groupname");
             String name = request.getParameter("name");
            String place = request.getParameter("place");
            String sex = request.getParameter("sex");
            String mobile = request.getParameter("mobile");

            try {
                Class.forName("com.mysql.jdbc.Driver");
                Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/"+groupname, "root", "root");
                Statement st = con.createStatement();
                Statement st1 = con.createStatement();
                 st.execute("create table memberdetail(groupname varchar(20),name varchar(20),place varchar(20),sex varchar(20),mobile int)");
                int i = st.executeUpdate("insert into memberdetail values('" + groupname + "','" + name + "','" + place + "','" + sex + "','" + mobile + "')");
            } catch (Exception e) {
                System.out.println(e);
            }
%>

i have created database for individual group based on the groupname... i lik to create table memberdetail and insert the details of the persons.. this code works gud to store single person... its not working wen i try to store more than 1 persons in memberdetail.. pls help me soon.....


December 30, 2014 at 9:35 PM


<%@page import="java.sql.*"%> <%@ page import="java.io.*" %> <% String groupname = request.getParameter("groupname"); String name = request.getParameter("name"); String place = request.getParameter("place"); String sex = request.getParameter("sex"); String mobile = request.getParameter("mobile");

        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/,dbname ,"root", "root");
            Statement st = con.createStatement();
            Statement st1 = con.createStatement();
             st.execute("create table memberdetail(groupname varchar(20),name varchar(20),place varchar(20),sex varchar(20),mobile int)");
            int i = st.executeUpdate("insert into memberdetail values('" + groupname + "','" + name + "','" + place + "','" + sex + "','" + mobile + "')");
        } 
        catch (Exception e) 
        {
            System.out.println(e);
        }

%>









Related Tutorials/Questions & Answers:
how to create database and table using jsp
how to create database and table using jsp  hi frnds...., i want to create database and table in mysql using jsp.... i have an registration form(name... table using jsp code... the table name should be the name of the person
how to display values from database into table using jsp
how to display values from database into table using jsp  I want to display values from database into table based on condition in query, how to display that? For example i have some number of books in database but i want
Advertisements
how to upload an image from a jsp page to a mysql database table using jsp
how to upload an image from a jsp page to a mysql database table using jsp  how to upload an image from a jsp page to a mysql database table using jspstrong text
how to create bar chart in jsp using msaccess database
how to create bar chart in jsp using msaccess database  type...: Unable to compile class for JSP An error occurred at line: 10 in the jsp file...\Tomcat 5.0\work\Catalina\localhost\chetana\org\apache\jsp\bar_jsp.java:61: cannot
how to create using jsp
how to create using jsp  code 1: <%@ page language="java...; <title>Create New Student</title> </head> <body> <form name="create" method="post" action="<
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript  when click on the next... to display previous 10records. Database Query like this: Select * from table
create bar chart in jsp using msaccess database
create bar chart in jsp using msaccess database  thanks for reply...) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758) org.apache.jsp.bar<em>jsp.</em>...) org.apache.jsp.bar<em>jsp.</em>jspService(bar_jsp.java:57
create bar chart in jsp using msaccess database
create bar chart in jsp using msaccess database  type Exception... to compile class for JSP An error occurred at line: 8 in the jsp file: /bar.jsp...\work\Catalina\localhost\chetana\org\apache\jsp\bar_jsp.java:57: cannot find symbol
how to display a table from database using servlet
how to display a table from database using servlet  how to display a table with values from servletpage   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 http://roseindia.net/jsp/servlet-jsp-data
how to fetch data from mysql database table and draw a bar chart on that data using in jsp
how to fetch data from mysql database table and draw a bar chart on that data using in jsp  how to create bar chart fetch data from mysql database using in jsp.please give me a right code. yhanks in advance
How to create bar chart using database values
How to create bar chart using database values  How to create bar chart using database values i.e excellent,good,average fields using jsp?It is like opinion poll.I want to show how many votes are came for excellent,good,average
Retrieve database from the table dynamically in jsp from oracle using servlet
Retrieve database from the table dynamically in jsp from oracle using servlet  Sir, I have created a table in oracle using eclipse, and added few... using java servlet from the database in the jsp page
Insert text into database table using JSP & jQuery
Insert text into database table using JSP & jQuery In this tutorial , the text is inserted into database table using JSP & jQuery. In the below... using "fadeIn" effect. The second JSP page contains code
how to use String tokenizer on table that is retrieved from database using jsp servlet
how to use String tokenizer on table that is retrieved from database using jsp servlet  Query:Table---- mysql> select pid,medicinename,dose,day,qty from medicinedetails2 where pid=15
Create a Table in Mysql database through SQL Query in JSP
Create a Table in Mysql database through SQL Query in JSP...; This is detailed java code to connect a jsp page to mysql database and create a table of given... two JSP pages. First page is to provide link to create table and the next page
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?   Hello Friend..."><input type="submit" value="Create Table"> </form> <% String
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database... to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts... example using struts.if anyone knows how to do it..please help me.. thanks a lot
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?  I have a project ie create an application for users to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts
Upload Excel into Database Table Using SERVLET - JSP-Servlet
Upload Excel into Database Table Using SERVLET  Hi i hava sitution that upload .xls file into database table which has same coloumn names... in database table are NAME,ID,SAL. please help me to upload that excel using
how to create online exam in jsp and database
how to create online exam in jsp and database  learing stage ,want to know how to create online exam
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
how to create bean using jsp and servlet
how to create bean using jsp and servlet  public class SampleBean... the following links: http://www.roseindia.net/jsp/usingbeansinjsp.shtml http://www.roseindia.net/jsp/loginbean.shtml
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what is wrong with my code? print("<% /* Create string...").newInstance(); /* Create a connection by using getConnection() method
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  how to insert check box value to the database using jsp my code is <link href...;table cellspacing="10" cellpadding="6" align="center" border="0" bgcolor="#D8E2F4
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's package. where the admin will select the activities to insert in the PACKAGE table. I
Create Dynamic Table using Hubernate
Create Dynamic Table using Hubernate  Thank's for reading my Post. I...: How to create seperate table for all users they sign up for my web app. i need... files but i done create and update for a single table. i dono how to automate
Using poi hwpf,how to create table in word document. - Java Beginners
Using poi hwpf,how to create table in word document.  Can you please tell me how to create a table in the word document in java using Apache poi hwpf.its very urgent.Please send some sample code.Thanks in advance
How to retrive database information using servlet and disply in table format in browser
How to retrive database information using servlet and disply in table format in browser  Hi, any one send code how to retrive the data base information in table format in web browser
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse  please help me i have to submit this soon
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap.  I have a jsp page which ask for project ID,team name,member name according to this data i have to retrieve their details from the database(oracle). I have
How can we create a database using PHP and mysql?
How can we create a database using PHP and mysql?  How can we create a database using PHP and mysql
How to search the selected item in row table using radia button in JSP?
How to search the selected item in row table using radia button in JSP?  How to search the selected item in row table using radia button in JSP
create webpage with table sql database using netbeans 6.8 with struts complete tutorial.(include username and password)
create webpage with table sql database using netbeans 6.8 with struts complete... with that project.i have an idea do create webpage using netbeans 6.8 version... webpage using java&j2ee.that webpage contain a home,carriers,contactus,about
PHP How to Create Table
PHP Create Table: In every database we need to create table, tables... by a row. To create a table we need to create a database first and then open it. (To know how to create and open a database please visit our web page: http
How to create database in mysql using ANT build - Ant
How to create database in mysql using ANT build  Hello , can anybody tell me how to create a database in mysql using ant build.Please tell... in build.xml to create a database: Create Database roseindia For more
Update Database Table using JDBC in JSP
Update Database Table using JDBC in JSP       This example shows how to update the existing  record of mysql table using jdbc connectivity in the jsp page
how to store data in other table using servlet and jsp
how to store data in other table using servlet and jsp  pls can anyone tell how to store data in other table using servlet and jsp and want to display that data too.and the data in first table must be same.pls help
how to create users using IBM Tivoi API in jsp/servelet?
how to create users using IBM Tivoi API in jsp/servelet?  how to create users using IBM Tivoi API in jsp/servelet
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
How to store values in a database using JSTL? - JSP-Servlet
How to store values in a database using JSTL?  I want to store values in a database... How can i store in database? Here is my code... This wil... in a database...How can i do? Airport
How to browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
JDBC: Create Table Example
JDBC: Create Table Example In this section, we are going to create table using JDBC and using database MySql. Create Table : Database table is collection... student in the database. For that we create connection to the database using jdbc
How to display image in jsp from database using Servlet?
How to display image in jsp from database using Servlet?  Hi, How to display image in jsp from database using Servlet? Thanks   Hi, You will find code and example program at Retrieve image from database using Servlet
how to create a table
how to create a table  create table tablename (name varchar(10),name.... Use the following query: create table tablename (name varchar(10),address... database table
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink
Retrieving images from the oracle database using jsp and create that rretrieved... want to retrieve images using jsp and I want to display on the browser.The...: http://www.roseindia.net/jsp/downloadimage.shtml
create using jsp
create using jsp  code 1:``<%@ page language="java" contentType..." content="text/html; charset=ISO-8859-1"> <title>Create New Student</title> </head> <body> <form name="create" method="post
Video Tutorial: How to create a database in MySQL using Command prompt?
How to create a database in MySQL using Command prompt MySQL is an Operation... is the video tutorial of "How to create database in MySQL using command prompt?": ADS_TO_REPLACE_1 In this tutorial we will learn how to create a database

Ads