Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to create database and table using jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Prakash
how to create database and table using jsp
3 Answer(s)      2 years and 4 months ago
Posted in : Java Beginners


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...


Advertisement
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.....



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 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: http://roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
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 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 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 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...="submit" value="Create Table"> </form> <% String tab
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...;head> <title>Create table in mysql database using jsp<
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 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
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
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 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
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 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
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 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 Create a Table.
How To Create a Table.  How To Create a Table?   Hi friends, If you want to create a table, you can run the CREATE TABLE statement..._config.php"; $sql = "CREATE TABLE user_info(" . " id INTEGER NOT NULL" . ", name
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... 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 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
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
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 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
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
Advertisements
 

 

 

DMCA.com