Home Answers Viewqa XML servelet and jdbc programming

 
 


Shridhu Chandel
servelet and jdbc programming
3 Answer(s)      4 years and 2 months ago
Posted in : XML

View Answers

March 21, 2009 at 4:17 AM


Hi friend,

Some steps to be remember for solving the problem :

1.Create a html page "stud.html".

<html>

<head>
<title>New Page 1</title>
</head>

<body>



<form method="POST" action="/student">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.txt";
S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p>Student Name:<input type="text" name="student_name" size="20"></p>
<p>Enrollment No: <input type="text" name="enrollment_no" size="20"></p>
<p>Course Code: <input type="text" name="course_code" size="20"></p>
<p>Regional Center Code: <input type="text" name="regional_center_code" size="20"></p>
<p>E-mail Id: <input type="text" name="email_id" size="20"></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="Submit" name="submit"></p>
</form>

</body>

</html>

March 21, 2009 at 4:18 AM


Step 2 : create a servlet class "Student.java"

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

public class Student extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
String connectionURL = "jdbc:mysql://localhost/zulfiqar";;
Connection connection;
try{

String student_name = request.getParameter("student_name");
String enrollment_no = request.getParameter("enrollment_no");
String course_code = request.getParameter("course_code");
String regional_center_code = request.getParameter("regional_center_code");
String email_id = request.getParameter("email_id");

Class.forName("org.gjt.mm.mysql.Driver");
connection = DriverManager.getConnection(connectionURL, "root", "admin");
PreparedStatement pst = connection.prepareStatement("insert into emp_info values(?,?,?,?,?)");

pst.setString(1,student_name);
pst.setString(2,enrollment_no);
pst.setString(1,course_code);
pst.setString(2,regional_center_code);
pst.setString(1,email_id);

int i = pst.executeUpdate();
if(i!=0){
pw.println("<br>Record has been inserted");
}
else{
pw.println("failed to insert the data");
}
}
catch (Exception e){
pw.println(e);
}
}
}

March 21, 2009 at 4:20 AM


3.In web.xml action mapping of servlet.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">;

<web-app>
<servlet>
<servlet-name>abc</servlet-name>
<servlet-class>Student</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>/student</url-pattern>
</servlet-mapping>
</web-app>

Thanks









Related Pages:
servelet and jdbc programming - XML
servelet and jdbc programming  Write a program using Servlet and JDBC for developing an online submission of an examination form. You are required...(); String connectionURL = "jdbc:mysql://localhost/zulfiqar"; Connection
jsp-servelet,error http404
jsp-servelet,error http404  I am using mysql commandclient to connect with eclipse using jsp and servelet. I keep getting the error hhtp 404...("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc
problem in creating web application using servelet, jsp, jdbc and xml - JSP-Servlet
problem in creating web application using servelet, jsp, jdbc and xml  Using Servlet, JSP, JDBC and XML create a web application for a courrier... the technologies JSP,Servlet and JDBC etc... Thanks
Servelet methods
Servelet methods  In my project we use the sendRedirect method which is nt working in our project i would like to know whether there is any other method which can be used instead of sendRedirect
applet and servelet
applet and servelet  How will you establish the connection between the servelet and an applet?  Hi, From applet you can use the URL class to call the servlet. URL servletURL = new URL( location ); URLConnection
java programming - JDBC
java programming  Develop a simple OPAC system for library using even-driven and concurrent programming paradigms of Java. Use JDBC to connect to a back-end database.please reply immediately sir
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to raichallp@yahoo.in
Programming error - JDBC
Programming error  import javax.servlet.*; import...=DriverManager.getConnection("jdbc:odbc:Odsn"); Statement s=con.createStatement(); int x...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc
java programming problem - JDBC
java programming problem  Hi, Request you to provide a solution ( analysis & design & unit test plan & code & test criteria ) to the following problem to the following mail id : Problem : upload excel file data into oracle
java servlet programming - JDBC
programming through servlets Thanx   Hi friend, i am sending multiple
servelet connectivity with oracle using procedure
servelet connectivity with oracle using procedure   kindly elaborate how servlet code connect to oracle br using procedure
Programming in JDBC and JSP - JSP-Servlet
Programming in JDBC and JSP  Write a program using JDBC and JSP to display the names and addresses of all those MCA students at your study centre who have completed/submitted their theory assignments of all the courses of IV
Web programming
Web programming  Write a program in servlet by using JDBC to display the records of employees from a table called employee
JDBC Architecture
JDBC architecture can be classified in 2 broad categories:- 1. JDBC API 2. Types of JDBC Drivers JDBC API     JDBC programming interface... the Drivers found in JDBC environment, load the most appropriate driver
JDBC
JDBC       JDBC stands... Connectivity (JDBC) API is the industry standard for database-independent connectivity between the Java programming language and a wide range of databases
error at programming
=DriverManager.getConnection("Jdbc:Odbc:mydsn"); Statement s =c.createStatement
error at programming
=DriverManager.getConnection("Jdbc:Odbc:mydsn"); Statement s =c.createStatement
error at programming
=DriverManager.getConnection("Jdbc:Odbc:mydsn"); Statement s =c.createStatement
error at programming
=DriverManager.getConnection("Jdbc:Odbc:mydsn"); Statement s =c.createStatement
error at programming
=DriverManager.getConnection("Jdbc:Odbc:mydsn"); Statement s =c.createStatement
error at programming
=DriverManager.getConnection("Jdbc:Odbc:mydsn"); Statement s =c.createStatement
error at programming
=DriverManager.getConnection("Jdbc:Odbc:mydsn"); Statement s =c.createStatement
error at programming
=DriverManager.getConnection("Jdbc:Odbc:mydsn"); Statement s =c.createStatement
error at programming
("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c =DriverManager.getConnection("Jdbc:Odbc:mydsn..."); Connection con = DriverManager.getConnection("jdbc:odbc:student"); Statement
JDBC Training, Learn JDBC yourself
JDBC Training       JDBC Training - Learn JDBC yourself: In this section we are providing free JDBC training material online. You can learn JDBC at your own
What is JDBC?
What is JDBC?       JDBC is Java application programming interface that allows the Java... written in the Java programming language. JDBC has been developed under
java - JDBC
programming language. For more information,Examples and Tutorials visit
Javascript - JDBC
should be displayed out. I am beginner in java field so using JDBC. anybody can... :-) Happy Programming. Regards, Y. Keerthi Sagar
Product Components of JDBC
. 1. The JDBC API. The JDBC application programming interface... version of  JDBC 4.0 application programming interface is divided into two... Product Components of  JDBC   
Programming Error - JSP-Servlet
Programming Error   Place Order function checkName... Orders Delete Orders View Orders Back Jdbc code: import...("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:Advdsn
Java Programming Question
Java Programming Question  Write a program in Java to create student information form an submit detail in database.   Hi Friend, Try...("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc
JDBC Components
includes four components: 1. The JDBC API The JDBC API gives access of programming... JDBC Components    JDBC stands for Java Database Connectivity. For connectivity with the database we uses JDBC
Programming
Programming  Given a number n, write a programming to determine its square root if it is possible, in the contraly case print an appropriate massege on the screen
Programming skills - JSP-Servlet
Programming skills  Hi, I visited this site for the first time.It's excellent. I want 2 improve my programming skills.Can u pls help me in making...; %><% Connection con = null; String url = "jdbc:mysql://localhost
Programming error - JSP-Servlet
Programming error  Register.jsp Registration Form function checkName(text) { if(isNaN(text)){ return 1;} else...=DriverManager.getConnection("jdbc:odbc:Advdsn"); PreparedStatement ps=con.prepareStatement("insert
programming error - Java Beginners
programming error  import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class Place_Ad extends...=DriverManager.getConnection("jdbc:odbc:Advdsn"); Statement s=con.createStatement(); ResultSet
programming error - Java Beginners
programming error  What is error in this page and how to use RequestDispatcher in servlet to validate it please do reply?? import javax.servlet....=DriverManager.getConnection("jdbc:odbc:Advdsn
java programming - Java Beginners
java programming  a simple program for library using event driven and use jdbc to connect backend database   Hi Friend, Try... =DriverManager.getConnection("jdbc:odbc:access","",""); Statement st
Features of JDBC
.style1 { text-align: center; } Feature A JDBC JDBC JDBC java database connectivity (JDBC) is an API (Application Programming Interface) for java that allows the Java programmer to access the Database. The JDBC API
Programming Error - JSP-Servlet
Programming Error  import javax.servlet.*; import java.io.*; import...=DriverManager.getConnection("jdbc:odbc:Advdsn"); Statement s=con.createStatement(); int x...=DriverManager.getConnection("jdbc:odbc:access"); Statement s=con.createStatement(); int x
java-sql - JDBC
java-sql  how to convert excel file into sql database usin java programming
Introduction to the JDBC
Introduction to the JDBC Introduction This article introduce you with JDBC and shows you how to our search engine with database.  What is JDBC? Java
programming
Java Constructor programming for single and double constructor  write a program which have no argument constructor ,single parameter constructor constructor,double parameter constor,and the now when we create a object
Interview question - JDBC
Interview question   Hi Friends, What is the return type of execute mehtod in jdbc .Thanks  Hi Rajendra, Whatever... Programming. Regards, Y. Keerthi Sagar
java programming - Java Beginners
{ Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc...("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql
java programming - Java Beginners
= DriverManager.getConnection("jdbc:mysql://localhost:3306/register", "root", "root
Java Socket Programming
"); //Defining connection URL String conurl="jdbc:odbc

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.