add record to database

add record to database

View Answers

May 3, 2008 at 6:54 PM

Hi friend,

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DataInsertionExam extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String url = "jdbc:mysql://localhost:3306/";;
String db = "register";
Connection conn;
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url+db,"root","root");
Statement statement = conn.createStatement();
String query = "insert into userdata values(1,'Amardeep', 'Programmer')";
int i = statement.executeUpdate(query);
if(i!=0){
out.println("The record has been inserted");
}
else{
out.println("Sorry! Failure");
}

statement.close();
}
catch (Exception e){
System.out.println(e);
}
}
}
-------------------------------------

<servlet>
<servlet-name>InsertDataExample</servlet-name>
<servlet-class>DataInsertionExam</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>InsertDataExample</servlet-name>
<url-pattern>/DataInsertionExam</url-pattern>
</servlet-mapping>

-------------------------------------

read for more information,

http://www.roseindia.net/servlets/









Related Tutorials/Questions & Answers:
add record to database - JDBC
add record to database  How to create program in java that can save record in database ?  Hi friend, import java.io.*; import java.sql....); if(i!=0){ out.println("The record has been inserted
Acess Record from database.
Acess Record from database.  How to access records from database and how to display it on view page, with the help of hibernate
Advertisements
hibernate record not showing in database - Hibernate
hibernate record not showing in database  session =sessionFactory.openSession(); //inserting rocords in Echo Message table...)); //It showing on console Records inserted 21 But not showing in database
retrive record from the text field and insert into to database
retrive record from the text field and insert into to database  the following code is inserting values in the my sql database but i want to insert the data into oracle database , i want what changes i have to make
fetch record from oracle database using jsp-servlet?
fetch record from oracle database using jsp-servlet?  how can i fetch data from oracle database by using jsp-servlet. i'm using eclipse, tomcat server and oracle database and creating jsp pages and also using servlet
Loading a jsp page (with record from database) from another jsp page
Loading a jsp page (with record from database) from another jsp page  ... with records from database(against Serial no and year).That is, as soon as Getdata.jsp will be loaded, it will show the first record. How can I do
How to retrive a particular record from database in php with mysql?
How to retrive a particular record from database in php with mysql?  Am using phpMyAdmin Database.In mysql database having 10 records. The field... record based on username and password. I dont know how to retrive in php with mysql
How to update record to database? I have trouble with the following code
How to update record to database? I have trouble with the following code ... the record,what is the missing of the following code ?I need help,thankyou <?php mysql<em>selectdb($database_con, $connection); $emailAddress=$_POST
Fetched Record from database show into text field of html page
Fetched Record from database show into text field of html page  hi, i have a database with field merchant_code, merchant_name, city, region, and also have html page with all above mentioned field i have submit 20 record from
How i upload file and save that record in database using JSP?
How i upload file and save that record in database using JSP?  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail form
How To Insert A New Record to MS Access table database in GUI
How To Insert A New Record to MS Access table database in GUI  Hello... that involves inserting a record into a 6-column table in my MS Access database table. I'm... on the Add button, it's not doing anything (not even my JOptionPane). I'm stuck
Check Whether Record is already Exists or Not with Database Connectivity - Java Beginners
Check Whether Record is already Exists or Not with Database Connectivity ... in the database with Swing Application ,if It is Already Exists then I want To Show MsgBox else that will Store in Database. plz Help Me Sir  Hi Friend, Try
How to add a column with checkboxes for each record in my table in JSP
How to add a column with checkboxes for each record in my table in JSP   Hi, Could you please explain it to me how I can add a column with check boxes for each record in my table in JSP? Also, I want to figure out a way
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST,please send answer as soo as possible
Add a file into database
Add a file into database  Provide the code to upload a file into oracle database?   1)page.jsp <%@ page language="java" %> <Html> <HEAD><TITLE>Display file upload form to the user</TITLE>
How to solve concurrency issue when an application is running on two machine to fetch record from one database
to fetch record from one database  I have developed an application in java to run on two machines. Program will fetch a record from database and process... are not fetching/processing same record at the same time. for example: if one machine fetches
Using C# DataGridView to insert record into Microsoft SQL Server 2005 database - SQL
Using C# DataGridView to insert record into Microsoft SQL Server 2005... creating a sales database system using C# and Microsoft SQL Server 2005. I had encounter a problem of using C# DataGridView to insert record into Microsoft
how to add database in Java Applet
how to add database in Java Applet  hi every java master or Java... to add database in Java Applet below this code is my applet source code . thank... to Rental Car System"); lab.setBounds(100,20,200,20); add(lab); label1 = new
How to Delete a column and Add a new column to database
How to Delete a column and Add a new column to database   How to Delete a column and Add a new column to database   Hi, The following query is executed for add and delete a column in a table-ADS_TO_REPLACE_1 for drop
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  In this code how i will use arraylist(which store all my records in index form) to show next data on button click,so that it will goes
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  In this code how i will use arraylist(which store all my records in index form) to show next data on button click,so that it will goes
Servlet to add the data into database
Servlet to add the data into database   ...; <description> Servlet to add the data into database <... the data in the database table from a html form.  This servlet program
record management application - Java Beginners
record management application  write a small record management application for a school.Tasks will be Add record, Edit record,Delete record, List records. Each record contains: name(max 100 char), Age,Notes(No Max.Limit
JSP to add details to a database from a HTML form.
JSP to add details to a database from a HTML form.  Hi I'm a second year CS student who has to use JSP to validate a HTML form and add the details entered into a database. The files are all in one folder for use in tomcat
jsp page to add users to mysql database
jsp page to add users to mysql database  <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@taglib uri="/WEB-INF/struts-bean.tld...-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Add
jsp page to add the user to mysql database
jsp page to add the user to mysql database  adduser.jsp: <%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@taglib uri="/WEB-INF...;title>Add User</title> </head> <form name="user" action
delete record
delete record  how to delete record using checkbox and button in php   We are providing you the jsp code that displays the database table... deleted from the database. In the database we have created three fields bookid
While creating a jar how to add MySQL database to project
While creating a jar how to add MySQL database to project  Hi, Please tell me how to attach MySQL database to the Java project while building a jar or their is any other process
JSP Delete Record From Table Using MySQL
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. In this example we will discuss about how to delete a record of database table
Database
Database  I am working in jsf2.Fro a demo i created database in ms access.no wi want to retrive a record from database for a particular data.I need help as I am stuck
how to make JTable to add delete and update sql database table
how to make JTable to add delete and update sql database table  Hello all I want to know how to make JTable to act actively to add delete and update database table. i am struck ed here from long time please help me
How to add a columns with a button set to a Jtable built with database result set
How to add a columns with a button set to a Jtable built with database result set  hi, i have to build a gui to display account numbers and account... that button column to the table which is built with database result set. i would thank
retrieve record from table
retrieve record from table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table. Actually
Add Items in JComboBox from Access Database - Java Beginners
Add Items in JComboBox from Access Database  Heelo Sir I want To add ittem in JComboBox which is stored in Access Database. plz Help Me Sir Database Column name -Course Items -MBA,MCA,MBA IT,MBA FINANCE I want Load Database
Edit the record.
Edit the record.  sir, I have a table consist of huge data.I have displayed that data.side of them there is an edit button which will edit... to previous edited row or edit the previous record of the previously edited
how to add data dynamically from database into a dropdown list in a jsp
how to add data dynamically from database into a dropdown list in a jsp ... in storing them into the database,this registration form contains name... get dynamically from the database and whenever a new person has registered his
How to add dynamically rows into database ?Need help pls
How to add dynamically rows into database ?Need help pls  Hi everyone...; <input type="button" value="Add Row" onclick="addRow();" /> <input...')"; $result = mysqli_query($link, $query) or die('Error querying database
ModuleNotFoundError: No module named 'Record'
ModuleNotFoundError: No module named 'Record'  Hi, My Python... 'Record' How to remove the ModuleNotFoundError: No module named 'Record'... to install padas library. You can install Record python with following command
retrieve record from the field table
retrieve record from the field table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table
How to retrieve record from table
How to retrieve record from table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table
how to fetch the record using AJAX? - Ajax
how to fetch the record using AJAX?  Can anyone tell me how to fetch the records from database using Ajax
sorting student record - Java Beginners
recording ? u want to store value in database or in file or opertinng run time specify   Here i gave only sample. As per ur wish u add method...(){ System.out.println("display"); //do ur work here } // Add what ever method u want
next and previous record in php
next and previous record in php  How to display next and previous records in PHP
Jsp code for disabling record.
Jsp code for disabling record.  I want a Jsp and servlet code for the mentioned scenario. Q. A cross sign appears in front of each record, click to disable the record.System marks the record as disabled.The record
database
database  database
database
database  database application
how to edit a record in hibernate?
how to edit a record in hibernate?  how to edit a record in hibernate?   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 Hibernate Tutorials Thanks   Hi Friend,ADS_TO_REPLACE_2 Please visit
Database Record findById
Database Record findById   ... Database table: student Model Class: Student.java Main Class... then record will be displayed otherwise not. /* * To change this template
query to fetch the highest record in a table
query to fetch the highest record in a table  Write a query to fetch the highest record in a table, based on a record, say salary field in the empsalary table
Database Record findByName
Database Record findByName       In this section, you learn to develop a jpa application to find... your conditions. You need the following artifacts:ADS_TO_REPLACE_1 Database

Ads