10 April, 2010

Database Connectivity in JSP

Database connectivity using JSP with MS Access

First Your need to post all the arguments from one webpage to another for that you need to write like this
in your form tag

method="post" action="database.jsp"

 Database connectivity page

// database.jsp


  <%@page import="java.net.URLEncoder" %>
  <%@ page import="java.net.*"%>
  <%@ page import="java.sql.*"%>
  <%

  try
  {
   String s1=request.getParameter("t1");
   String s2=request.getParameter("t2");
   String s3=request.getParameter("t3");
   String s4=request.getParameter("t4");

               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               Connection con=DriverManager.getConnection("jdbc:odbc:login"," "," ");
    

/* login is the your System DNS driver name which can be created as by these steps      go to control panel  double click on Administrative tools then double click on Datasource (ODBC) then select the System DNS from upper bar then click to add and select the Microsoft Access Driver (.mdb) then click on finish give the Data source name and click on select and selct the access file where it present then click ok every where and come out Note that Data Source name is your System DNS which will be written instead of Login in connection statement
             
*/

           Statement st=con.createStatement();
      
           st.executeUpdate("INSERT INTO profile VALUES ('" + s1 + "','" + s2 + "','" + s3 + "','" + s4 +"')");

con.close();
}                                      
catch(Exception e){}

%>

Udaipurwati

UDAIPURWATI

Udaipurwati is a Town in shekhawati region and a municipality. It is in Jhunjhunu District in Rajasthan state

of India.

Location:-
Country : India
State : Rajasthan
District: Jhunjhunu
Population: Approx. 30,000 as(2001)

History


Thakur Bhojraj (shekhawat) was the ruler of Udaipurwati. He was a Good King and the ancestor of Bhojraj ji ka Shekhawats. The group of 45 villages of Udaipurwati was known as Pentalisa. The Shekhawat Thakurs of Pentalisa paid allegiance to their overlords, the Maharajas of Jaipur, which was collected from Udaipurwati. The famous villages of Pentalisa was Jhajhar,Khirod , Chirana, Gudhagorji etc.