problem on jsp, inserting data into table(mysql).

problem on jsp, inserting data into table(mysql).

hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database is in mysql.I want to use placeholder("?") to insert data into table.Plsssss help me... Thanks in advance.

View Answers

March 31, 2011 at 1:19 PM

1)form.html:

<html>
<form method="post" action="http://localhost:8080/examples/jsp/insertdata.jsp">
<table>
<tr><td>Table Name:</td><td><input type="text" name="tname"></td></tr>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)insertdata.jsp:

<%@page import="java.sql.*,java.util.*"%>
<%
String tname=request.getParameter("tname");
String name=request.getParameter("name");
String address=request.getParameter("address");
        try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        PreparedStatement pst=con.prepareStatement("insert into "+tname+"(name, address)values(?,?)");

            pst.setString(1, name);
            pst.setString(2, address);
            pst.executeUpdate();
        con.close();
        out.println("Data is successfully inserted into database.");
        }
        catch(Exception e){
        System.out.println(e);
        }
        %>









Related Tutorials/Questions & Answers:
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database
Problem in inserting clob data in jsp
Problem in inserting clob data in jsp  how to insert any rich text editor data (which have more than 32766 characters) in a clob type column of oracle database with jsp
Advertisements
problem in inserting data in databases created in netbeans using jsp..
problem in inserting data in databases created in netbeans using jsp..  i am trying to make a virtual classroom website in jsp using netbeans.i created table inside netbeans through sql editor.and tried to make a login page whose
Inserting Data into mysql - SQL
Inserting Data into mysql  My sincere apologize for this post. I... (using php)and inserting the details in a mysql database. Lets take for instance, a csv file named books and a database table named books as well both
problem in inserting data in databases created in ecplise using jsp
problem in inserting data in databases created in ecplise using jsp  <%@ page language="java" contentType="text/html; charset=ISO-8859-1...;table class="contact"> <tr><td align="right
problem in inserting data in databases created in ecplise using jsp
problem in inserting data in databases created in ecplise using jsp  <%@ page language="java" contentType="text/html; charset=ISO-8859-1...;table class="contact"> <tr><td align="right
dynamic retrivel of data from mysql database in table format at jsp
dynamic retrivel of data from mysql database in table format at jsp  ... the data from database and display it as table format in jsp... For example, i have... and also details of each member should be displayed in the table format in jsp
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
unable to display table data on JSP page that is coming from mysql and servlet.
unable to display table data on JSP page that is coming from mysql and servlet.  I am unable to show table data on JSP page using servlet and mysql. only two rows data i showing but in my database I have five fields
Inserting values into a database table of selected DropDown in jsp.
Inserting values into a database table of selected DropDown in jsp.  ... to insert all selected values in data base correspondent to each like if user selected india and then goa. I want to insert it to a table which has two fields
Data is not inserting correctly in mysql database.
Data is not inserting correctly in mysql database.  Hello Sir, below is my code to insert data into database by list iteration... for each data cloumn ..at the time of end of the query... PLz see my code and point my
Inserting data on a database in servlet - JSP-Servlet
to a databse by a servlet.I used the example in "Inserting Data In Database table...Inserting data on a database in servlet  Hi I am following... of a table,that is none of the data which i tried to enter into database by using
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
inserting data from radio buttons to database-ERROR - JSP-Servlet
inserting data from radio buttons to database-ERROR  hi, i have already changed the option field of table question. the code which you give me has the option field as options. but it is option in the table,so i changed
inserting data from radio buttons to database - JSP-Servlet
inserting data from radio buttons to database  hi, i am getting... an error in your SQL syntax; check the manual that corresponds to your MySQL...'' at line 1 please provide me the solution of this problem. thanks
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
Retrive only requird data from a table in MYSQL databade to JSP file..on a field submit button.
Retrive only requird data from a table in MYSQL databade to JSP file..on a field submit button.  i have MYSQL DB,DB NAME:TRLIST, TABLE NAME:TR_LIST... from table TR_LIST on typing TR values in an input-text-box and by clicking<
Implementing Bean with script let in JSP
it with script let of jsp for inserting the data in mysql table. In this example we create a jsp page for taking the user name to insert in the database table... Implementing Bean with script let in JSP
Records are not inserting in to main table while running the mysql stored procedure.
Records are not inserting in to main table while running the mysql stored... that procedure records are not inserted into main table from temp table.But im getting msg... me with this issue. My Code: BEGIN select concat('Inserting into SD
Insert Data in Table Using Stored Procedure
Insert Data in Table Using Stored Procedure ... data into a table using stored procedure. Steps: 1.Create database... Your data has been inserted into table. Download the source code
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.
How to display data fom MySQL DataBase-table in to JSP file by submitting a value in combobox.   I have the same problem.plz help me. I have MySQL DataBase/DB Name:lokesh; Table Name:TR_list; columns:nodename,packageno,TR
php inserting date into mysql
php inserting date into mysql  php inserting date into mysql   Here is a php code that inserts date into mysql database. In the given code, data is a database table. <?php table $query_manual = "INSERT INTO data
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
problem connect jsp and mysql - JSP-Servlet
problem connect jsp and mysql  hello, im getting an error while connecting jsp and mysql. I have downloaded the driver mysql-connector... Software Foundation\Tomcat 5.5\common\lib\mysql-connector-java-2.0.14.jar
inserting data from radio buttons to database - JSP-Servlet
inserting data from radio buttons to database  hi, my problem... button) now i have a database as professor and a table in this database as question. question table contains following fields: questionid, question, option
Inserting values in MySQL database table
Inserting values in MySQL database table   ... insert values in the MySQL database table. We know that tables store data in rows... the facility for inserting the values in MySQL database table. Description
How to insert data into MySQL Table?
How to insert data into MySQL Table?  Hi, How to insert the data into MySQL Database? Please explain me with the examples and videos thanks. Thanks   Hi, The insert into query is used to insert the data into MySQL
inserting dropdown values into database table
inserting dropdown values into database table   hi i want to insert dropdown values into a database table by using jsp
inserting value - JSP-Servlet
the jsp inserting the value in the jsp after that i want these value inserted the database mySQl with the help of servlet. Inserting form data   Inserting form data into database using JSP and ServletGiven code will illustrate you
Dynamic table data to Excel in JSP
Dynamic table data to Excel in JSP   Iam trying to export dynamic data to excel . But it is displaying only static data .Kindly help viewtrial.jsp...() { document.form1.des.disabled=0; } function view_Table() { } function
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...; <form method="post"> Enter Table Name:<input type="text" name="table
Insert Blob(Image) in Mysql table using JSP
Insert Blob(Image) in Mysql table using JSP In this Section, we will insert blob data(image) in Mysql database table using JSP code. A Blob stores a binary..._TO_REPLACE_8 See also :   Display Blob(Image) in Mysql table using
To save table format data in pdf/excel in jsp
To save table format data in pdf/excel in jsp  Hello, I am doing web application project in jsp. In webform ,I am displaying database data in html table. So my question is ,I want so save this html format data in pdf/excel format
MYSQL retrieve record from Data table
MYSQL retrieve record from Data table  Hi. I have a field in database...,kanchipuram for a single record. I have to retrieve these data from the field table. Actually they are separated by comma. I want to take the values as single
Problem in enctype="multipart/form-data" in JSP
Problem in enctype="multipart/form-data" in JSP  im using a page which is in JSP. i have some text boxes and one upload button. i want to load the file itself when i click the submit button. im using enctype="multipart/form-data
MySQL issue: Table 'data_dictionary.CHARACTER_SETS' doesn't exist
MySQL issue: Table 'data_dictionary.CHARACTER_SETS' doesn't exist  MySQL issue: Table 'datadictionary.CHARACTERSETS' doesn't exist
JSP with Mysql
JSP with Mysql  Hi sir, I trying to several time but i am not get an answer. My questions are 1. How to inserting same field data to different mysql table using jsp. That is creating a form with 5 fields,data's are same
Inserting a value to an Enum field in Table
Inserting a value to an Enum field in Table  I'm writing a code that creates a user account and sends the result to the user table in a mysql database. For example, in the user table I have: username varchar(15) PRIMARY KEY
Display Blob(Image) from Mysql table using JSP
Display Blob(Image) from Mysql table using JSP In this section, we will display blob data(image) from Mysql database table using JSP code. A Blob stores... Also : Insert Blob(Image) in Mysql table using JSP Download Source CodeADS
hibernate firstExample not inserting data - Hibernate
problem is data is not inserting into DB even though the program is executed...("inserting records in Contact table"); Contact contactBO = new Contact... DEFAULT CHARSET=latin1 data is not inserting
Upload Exce Data into MySql Using Jsp and Servlet - JSP-Servlet
Upload Exce Data into MySql Using Jsp and Servlet  now i am doing a project my concept is to insert the Excel File Data is uploaded and inserted into Mysql Database table so please give the coding to me, it's very urgent for me
how to insert the bulk data into the data base from the table of jsp page to another jsp page
how to insert the bulk data into the data base from the table of jsp page to another jsp page  pls help i'm doing the project called centralized management system for school and college based here i have a problem that i have
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
how to display data in List Or grid or in table in Jsp
how to display data in List Or grid or in table in Jsp   <%@page... String P Value in List GIrd or Table please help am able to Print display data...;JSP Reading Text File</title> </head> <body> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Inserting Image into table
Inserting Image into table  In this section , we will insert a image into a table. For inserting image, table's field (in which image will be stored) must be define as "blob". First, Create table'inImage'
jsp problem
jsp problem  problem:::::::: On JSP form ,when i insert data in text field........at that time action is perform and data is retriev from data base and get assign to other field on that form........ when data is assign to other
Read Excel data using JSP and update MySQL databse
Read Excel data using JSP and update MySQL databse  HOw to read excel data using JSP and update MySQl database

Ads