Home Answers Viewqa JDBC add record to database

 
 


flodena
add record to database
1 Answer(s)      5 years and a month ago
Posted in : JDBC

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 Pages:
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
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
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
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
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
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
Record management application for a school
has been stored in the text files.Through this application, you can add record...); tp.addTab("Add Record", p1); tp.addTab("Edit Record", p2); tp.addTab...Record management application for a school In this section, we are going
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
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
How to refresh a jTable On adding or deleting record ....
from database and displayed in panel... Now i have to add records in the database...How to refresh a jTable On adding or deleting record ....   Hii... of records.... and new record should be showed in the jtable in the panel.. Plz sir give
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
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 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>
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
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
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
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 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
Add Edit And Delete Employee Information
Add Edit and Delete Employee Information Using Swing       In this section, you will learn how to add, edit and delete the Employee's information from the database using java swing
sort a record in jsp - JSP-Servlet
sort a record in jsp  hello, can i get a code that displays 10... it displays the next 10 pages and so on. Im using jsp and mysql database. thx priya... In the above code,we have taken the database table student
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 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- for drop a column
JDBC Insert Record
JDBC Insert Record      ... Record. In this code we have a class JdbcInsertRecord.Inside this class... a connection object. This help in built a connection between url and database
Mysql Last Record
Mysql Last Record       Mysql Last Record is used to return the last records from table... an example from 'Mysql Last Record'. To understand example we create a 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
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
MYSQL retrieve record from Data table
MYSQL retrieve record from Data 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
HTML & MYSQL - retrieve record from table
HTML & MYSQL - 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
fetch record from MYsql table query
fetch record from MYsql table query  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
retrieve record from table and show it in HTML
retrieve record from table and show it in HTML  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
Database
of category.i want the following things 1)possible for the admin to add some more subjects in the category in the web page. 2)when admin add some subjects then automatically save that subjects in my database for this i want procedure some
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 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
JDBC Select Record Example
JDBC Select Record Example  In this tutorial we will learn how select specific  record from table use mysql JDBC driver. This  select... all row record that user_name =User1.The code of   "
database
user required data from the database and rank the results and display... that) based on that system search it to the database and rank the results and retrieve it to the user. other than this what i ll add to improve my applications. i
problem in database
problem in database   thanks for web site. I want change this code to insert data into PostgreSql database using jsp,servlets. but i getting output "Record has been inserted", 1.no data in the table(sample) public
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
database
database  in my database i add some fields.the total fields are first name,last name,email,password,conform password,date of birth,age,gender,address,country,state,city,telephone,mobile, how did u hear about us. but i got some
The INSERT INTO Statement
The INSERT INTO Statement       The INSERT INTO statement is used to insert or add a record...'. . .); Insert a New Row To insert a new row in a database table we have to write
Database
also if admin add the one more subject under the category field in the web site
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
Database Record findById
Database Record findById   ...). This method finds data by primary key. You need the following artifacts: Database... "1". If primary key is found then record will be displayed otherwise
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: Database table: student
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
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

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.