Databases

Ads

 
 

Share on Google+Share on Google+

Dhaval B Leuva
Databases
1 Answer(s)      6 years and 4 months ago
Posted in : JSP-Servlet

how to add data dynamically into the database table?? i used back end is mysql....

Ads
View Answers

May 2, 2011 at 10:41 AM


1)form.jsp:

<html>
<form method="post" action="insertdata.jsp">
<table>
<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>Contact No:</td><td><input type="text" name="contact"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)insertdata.jsp:

<[email protected] import="java.sql.*"%>
<%
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");

        try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        Statement st=con.createStatement();
        int i=st.executeUpdate("insert into employee(name,address,contactNo,email) values('"+name+"','"+address+"',"+contact+",'"+email+"')");
        out.println("Data is successfully inserted into database.");
        con.close();
        }
        catch(Exception e){
        System.out.println(e);
        }
        %>

Ads









Related Tutorials/Questions & Answers:
Switch databases
Switch databases  How do you inter-change between relational databases without code changes
Advertisements
Databases supported by Jdeveloper?
Databases supported by Jdeveloper?  I want to know what databases are supported by jdeveloper ?and any light database for jdeveloper
mysqldump all databases
mysqldump all databases  How to take the backup of complete data including all the databases in the MySQL Server? Is there one command to take...-databases > all_databases.sql Thanks
Merge databases in SQL SErver 2005
Merge databases in SQL SErver 2005  Please help me to merge databases in SQL server 2005
Version of cocoon>cocoon-databases dependency
List of Version of cocoon>cocoon-databases dependency
Upgrading databases between MySQL 5.0 to MySQL 5.5
Upgrading databases between MySQL 5.0 to MySQL 5.5  Upgrading databases between MySQL 5.0 to MySQL 5.5
Biological Databases Links
Biological Databases       Biological Databases are like any other databases... databases: Biological Database Links
Maven Dependency cocoon-databases >> 2.1.3
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-databases version2.1.3 in your project
Maven Dependency cocoon-databases >> 2.1.5.1
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-databases version2.1.5.1 in your project
Maven Dependency cocoon-databases >> 2.1.6
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-databases version2.1.6 in your project
Maven Dependency cocoon-databases >> 2.1.8
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-databases version2.1.8 in your project
Maven Dependency cocoon-databases >> 2.1.4
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-databases version2.1.4 in your project
Maven Dependency cocoon-databases >> 2.1.7
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-databases version2.1.7 in your project
is it possible to connect the multiple databases from the hibernate application
is it possible to connect the multiple databases from the hibernate application  is it possible to connect the multiple databases from the hibernate application,if it is possible then tell me with step wise manner
Hibernate 4 Supported Databases List
Hibernate 4 Supported Databases List In this tutorial you will learn that how many databases are supported by Hibernate. You must be looking for the list... be configured to work with other databases. This feature of Hibernate is handled
need help....how to connect and disconnect multiple databases(databases created in mysql) using java and my sql
need help....how to connect and disconnect multiple databases(databases created in mysql) using java and my sql  i am working on a project... to know that how to query multiple databases(databases created in my mysql) so
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" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> JS Soft
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" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> JS Soft