Insert & Retrieve data from M.S Access/SQL table using Java Servlet Programming

Home  »  Java  »  Advance Java  »  Java Servlet  »  Insert & Retrieve data from Table


The following are two Java Servlet programs Client Side and Server Side. One Program will insert a data into M.S.Access/SQL table and second will retrieve data from M.S.Access Table. For this first of all you need to create a M.S.Access database or SQL... but in this example I'm using M.S.Access. Create one table in M.S Access as shown below:


Table Definitions:

Table Name: [ICTCashBook.mdb]-Download
Primary Key: VoucherNo
Foreign Key: Nil

Column Definition:
Column NameData Type
IDAutoNumber
SessionText
MonthText
DDNumber
MMNumber
YYNumber
VoucherNoNumber
ArticlesMemo
FromWhichPurchsedMemo
AmountNumber
RemarksMemo

Table Description:
Column NameDescription
IDCreate AutoNumber for image id
Sessioninsert Session for ex. 2011-12
Monthinsert month in text...
DDinsert date in numeric
MMinsert month in numeric
YYinsert year in numeric
VoucherNoinsert unique numeric no
Articlesinsert text
FromWhichPurchsedinsert text
Amountinsert numeric value
Remarksinsert text/numeric value



After create table in M.S. Access database now you will create DSN.

Following is the client side source code of the MonthlyExpenditureClient.java





Complete Source Code of MonthlyExpenditureClient - Download



Now, Server-Side coding....





Complete Source Code of MonthlyExpenditure - Download



"Start -> All Programs -> Apache Tomcat 4.0 -> Start Tomcat." and minimize window


How to Install Apache Tomcat 4.0 then Click Here

and for Download Apache Tomcat 4.0 then Click Here


Now compile the above both code using javac compiler...









Now, copy "SimpleServlet.class" and "MonthlyExpenditure.class" Files from c:/jdk1.4/bin/ and then paste it under below dir...



"C:/Program Files/Apache Tomcat 4.0/webapps/examples/WEB-INF/classes/"



or use below command











or you can use "*.class" for copy all classes...







Now Open any web browser and type client side URL into address bar as below...






Inserting records into M.S Access Table


Opening records from M.S Access Table



7 comments:

  1. This is good information about retrive data from ms access to sql. More useful.

    Microsoft Access to SQL Server Migration

    ReplyDelete
  2. Thanks For Sharing his nice post. Read Our Article in Fitness And Health Releted.
    web Development Company in Surat

    ReplyDelete
  3. Good Post! Thank you so much for sharing the post, it was so good to read and useful to improve
    Java Training in Electronic City

    ReplyDelete
  4. Visit our website accessdatabasedevelopment.co.uk/ for develop custom databases tailored to your business needs and providing your business with a competitive advantage by enabling you to increase efficiency, enhance quality of service and make the work lives of staff simpler. We ms access database design company in UK specialise in building bespoke business database solutions and form creation in ms access using industry standard tools such as Microsoft Access.

    ReplyDelete
  5. Visit our website accessdatabasedevelopment.co.uk/ for develop custom databases tailored to your business needs and providing your business with a competitive advantage by enabling you to increase efficiency, enhance quality of service and make the work lives of staff simpler. We microsoft access development in London specialise in building bespoke business database solutions and form creation in ms access using industry standard tools such as Microsoft Access.

    ReplyDelete
  6. Thankyou for sharing such as nice post. It is really helpful for developer, Keep it sharing
    Visit our website accessdatabasedevelopment.co.uk/ for develop custom databases tailored to your business needs and providing your business with a competitive advantage by enabling you to increase efficiency, enhance quality of service and make the work lives of staff simpler. We microsoft access database development London specialise in building bespoke business database solutions and form creation in ms access using industry standard tools such as Microsoft Access.
    microsoft access developer London

    ReplyDelete