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



Home Answers Viewqa JSP-Servlet problem on jsp, inserting data into table(mysql).
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


rohit
problem on jsp, inserting data into table(mysql).
1 Answer(s)      3 years and 8 months ago
Posted in : JSP-Servlet


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.


Advertisement
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
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 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
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
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
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
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
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
Insert Data in Table Using Stored Procedure
Insert Data in Table Using Stored Procedure        In this example we are inserting data... Your data has been inserted into table. Download this example.(Java
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
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
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
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
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
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
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<
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
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 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
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
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
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
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
inserting data into datafields
inserting data into datafields  I was raised with a query.... there is a button, on click on it....... few fields regenerates and the details entered there should be inserted into Database Number of times we click that button
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
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
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... Blob(Image) in Mysql table using JSP Download Source Code
 

 

 

DMCA.com