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

 
 


Prakash
how to create database and table using jsp
3 Answer(s)      9 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...

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 Pages:
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 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="<
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 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
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 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
Create a database
database. Then create a database using the given syntax and give the suitable name... Create a database       In this section, we will teach you to create a database.  First of all
Navigation in a database table through jsp
Navigation in a database table through jsp  .... Create a database:  Before run this jsp code first create a database named... :- mysql> create database student; Then create a table named 'stu
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
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 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
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 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 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 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 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
JSP Delete Record From Table Using MySQL
JSP Delete Record From Table Using MySQL This tutorial explains you that how to write a JSP for deleting a record from database table. In this section you.... In this tutorial you will learn that how to delete a record of a database table in 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
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
JDBC : Create Database Example
JDBC : Create Database Example In this section you will learn how to create database using JDBC with example. Create Database : Database is an organized... the data.In Our discussion we are using MYSQL database. It is Relational DBMS so
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 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
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
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
how to create a new table for the already existing user in the website
how to create a new table for the already existing user in the website  haiii....i want the code in jsp "how to create a new database for every user that has been already existing in the website?"....plzzzz help me
PHP Create Database
PHP Create Database To create Database in MySQL: $) Using MySQL console: i...)    Type create database database_name. Enter your desired database name in place of database_name e.g. create database student or create
Insert a row in 'Mysql' table using JSP Code
Insert a row in 'Mysql' table using JSP Code In this section, we will discuss about how to insert data in Mysql database using JSP code. Query for creating database table : create database ankdb; create table stu_info
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
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 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 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
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based on employee id ename and designation are displayed how it is possible in jsp employee
Table
Table  How i create table on showMessageDialog using JOptionpane and Integer.parseInt. No other method to use. Pl make a program which generate 5X1=5 5X2=10 5X3=15   Hi Friend, Try this: import javax.swing.*; import
Uploading an image into the table - JSP-Servlet
a connection by using Connection interface Connection connection = null; /* Create...(); /* Create a connection by using getConnection() method that takes...Uploading an image into the table  how to upload an image
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
Using MYSQL Database with JSP & Servlets.
Using MYSQL Database with JSP & Servlets.  ...(;). Now we will  create a table in the database 'test...; In this section you learned how to work with MySQL database server, create database
Create a Table - Java Beginners
Create a Table in Java  How can i create table in Java?  Java Example Code - Creating table in JAVA... CreateTable(); } public CreateTable(){ JFrame frame = new JFrame("Create table
How to Extract row from table view using JSP Code - Java Beginners
How to Extract row from table view using JSP Code  Hi Friends...)deleteuser.jsp: For the above code, we have used following database table: CREATE TABLE `register
Deleting a Table from Database
database. But how we can delete the table using java methods and API. In this section we are describing, how to delete a table from database using java methods... Deleting a Table from Database   
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
Display Sum of Table Column Using In JSP
Display Sum of Table Column Using In JSP... the total salary between two specific date and result is display using Jsp... compile the java code using javac command from command prompt. Step 5:Create
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 create a databaseconnectvity using SQLSERVER2005 in J2ME - JDBC
how to create a databaseconnectvity using SQLSERVER2005 in J2ME  hi , iam new to J2ME,i want to know, How to create a data base connectivity... the database code in jsp , how to call the jsp in midlet(J2me app). please kindly
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
JSP Financial Year Table
JSP Financial Year Table  Im trying to design a financial year table... confused on to the JSP part as using an array is not possible. I have tried using... i have doubts on how to read the hashmap data and insert the same in database
Create Table in Database
example for the beginners, to create a table in database. In this Tutorial, we are using MySQL command query to create a table in database name countryinfo... Create Table in Database   
Ant Script to Create Mysql Table
Ant Script to Create Mysql Table       This example illustrates how to create table through... are using 4 property elements for connectivity of database. The first property
Access all the fields from table through JSP
Access all the fields from table through JSP.... This is first jsp page that has a link 'show data from table', which displays all the data from table when clicked. This is the code of first welcome jsp page. 
Create dynamic page through JSP
running this jsp code, first create a database named 'student' through the sql query... database student; Then create a table named 'stu_info' in the same database through following sql query :- create table stu_info

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.