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);
        }

%>

Ads









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... org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 10 in the jsp file: /bar.jsp Generated servlet error: C:\Program Files\Apache Software
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
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
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... org.apache.jasper.JasperException: Unable to compile class for JSP An error occurred at line: 8 in the jsp... Foundation\Tomcat 5.0\work\Catalina\localhost\chetana\org\apache\jsp\bar_jsp.java:57
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
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
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
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 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...;head> <title>Create table in mysql database using jsp<
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 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
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
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
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
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
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
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 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
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 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 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
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 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 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
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
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 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
How to create textbox on combo value selection using javacsript in jsp?
How to create textbox on combo value selection using javacsript in jsp?  dynamically create textbox on combo value selection. when select multiple values then create multiple textboxes
how to create xls file and give download option using jsp/servlet?
how to create xls file and give download option using jsp/servlet?  Hi, how to create file and give download option to user,so that the user can save the file on defined path
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  Hai masters i am new to this Java world. my team leader ask me to generate sales report data from oracle database to jsp page please any one know how to do
How i upload file and save that record in database using JSP?
How i upload file and save that record in database using JSP?  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail form
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?": In this tutorial we will learn how to create a database in MySQL using
how to read values from excel sheet and compare with database using jsp
how to read values from excel sheet and compare with database using jsp  hi sir i am arun how to read values from excel sheet and compare with database using jsp coding i.e, if i have 6(assetid,assetname,serialno,cubical
How to get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  ... database using JSP Get data from database using JSP... by using servlet or jsp program by typing the output as like this below
How to create file and save it into user defined path using jsp/servlet?
How to create file and save it into user defined path using jsp/servlet?  Hi.. Onclick event I have created one file.When file will create it should asked where to save file(like browse option
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... are creating table, named student in the database. For that we create
How I Upload File and Store that file name in Database using JSP
How I Upload File and Store that file name in Database using JSP  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail
how to check username & password from database using jsp
how to check username & password from database using jsp  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 display data from mysql table in text box using jsp??
how to display data from mysql table in text box using jsp??  <p>hi, i have a written a code to display data from a mysql table into txtboxes... at line: 113 in the jsp file: /Cat1.jsp The local variable v_RGPC may not have
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
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i want to delete this information in table when click on delete button and save

Ads