Pages

Ads 468x60px

Friday 21 December 2012

Week-9 java program/servlet/JSP to connect to that database and extract data

Week-9                                                                                               Date:
------------------------------------------------------------------------------------------------------------
 AIM:   Install a database (Mysql or Oracle).
            Create a table which should contain at least the following fields: name, password, email-id, phone number (these should hold the data from the registration form).
Practice 'JDBC' connectivity.
Write a java program/servlet/JSP to connect to that database and extract data from the tables and display them. Experiment with various SQL queries.
Insert the details of the users who register with the web site, whenever a new user clicks the submit button in the registration page (week2).

DESCRIPTION:

JDBC Driver Types  
There are four types of JDBC drivers in use:  
Type 1: JDBC-ODBC Bridge 
A Type 1 JDBC-ODBC Bridge provides application developers with a way to access JDBC drivers via the JDBC API. Type 1 JDBC drivers translate the JDBC calls into ODBC calls and then send the calls to the ODBC driver. Type 1 JDBC drivers are generally used when the database client libraries need to be loaded on every client machine. 
Type 2: Native API/Partly Java Driver 
A Type 2 Native API/Partly Java Driver is a partial Java driver because it converts JDBC calls into database specific calls. Type 2 Native API/Partly Java Driver communicates directly with the database server. 
Type 3: Pure Java Driver  
A Type 3 Pure Java Driver works in a three tiered architecture. The JDBC calls are passed via the network to the middle tier server. This server translates the calls to the database specific native interface to further request the server. JDBC drivers available from Simba are Type 3 drivers. 
Type 4: Native Protocol Java Driver  
The type 4 driver is written completely in Java and is hence platform independent. It is installed inside the Java Virtual Machine of the client. It provides better performance over the type 1 and 2 drivers as it does not have the overhead of conversion of calls into ODBC or database API calls. Unlike the type 3 drivers, it does not need associated software to work.A Type 4 Native Protocol Java Driver converts JDBC calls into the database specific calls so that the client applications can communicate directly with the server.

PROGRAM:
Registration.html:
<html>
<head>
<title>Registration page</title>
</head>
<body bgcolor="#00FFFf">
<form METHOD="POST" ACTION="register">
<CENTER>
<table>
<center>
<tr> <td> Username </td>
<td><input type="text" name="usr"> </td> </tr>
<tr><td> Password </td>
<td><input type="password" name="pwd"> </td> </tr>
<tr><td>Age</td>
<td><input type="text" name="age"> </td> </tr>
<tr> <td>Address</td>
<td> <input type="text" name="add"> </td> </tr>
<tr> <td>email</td>
<td> <input type="text" name="mail"> </td> </tr>
<tr> <td>Phone</td>
<td> <input type="text" name="phone"> </td> </tr>
<tr> <td colspan=2 align=center> <input type="submit" value="submit"> </td> </tr>
</center>
</table>
</form>
</body>

Login.html
<html>
<head>
<title>Registration page</title>
</head>
<body bgcolor=pink> <center> <table>
<form METHOD="POST" ACTION="authent">
<tr> <td> Username </td>
<td><input type="text" name="usr"></td> </tr>
<tr> <td> Password </td>
<td> <input type="password" name="pwd"> </td> </tr>
<tr> <td align=center colspan="2"><input type="submit" value="submit"></td> </tr>
</table> </center>
</form>
</body>
</html>
 
Ini.java:
import javax.servlet.*;
import java.sql.*;
import java.io.*;
public class Ini extends GenericServlet
{
private String user1,pwd1,email1;

public void service(ServletRequest req,ServletResponse res) throws ServletException,IOException
{
user1=req.getParameter("user");
pwd1=req.getParameter("pwd");
email1=req.getParameter("email");
res.setContentType("text/html");
PrintWriter out=res.getWriter();
try
   {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con=DriverManager.getConnection("jdbc:oracle:thin:@195.100.101.158:1521:cclab","scott","tiger");
   PreparedStatement st=con.prepareStatement("insert into personal values(?,?,?,?,?,?)");
 st.setString(1,user1);
st.setString(2,pwd1);
st.setString(3,"25");
st.setString(4,"hyd");
st.setString(5,email1);
st.setString(6,"21234");
st.executeUpdate();
con.close();
  }
catch(SQLException s)
{  out.println("not found "+s);
}
catch(ClassNotFoundException c)
{ 
   out.println("not found "+c);
}
} }

web.xml:
<web-app>
<servlet>
<servlet-name>init1</servlet-name>
<servlet-class>Ini</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>init1</servlet-name>
<url-pattern>/regis</url-pattern>
</servlet-mapping>
</web-app>

OUTPUT:
http://wikibrand.blogspot.in
http://wikibrand.blogspot.in

http://wikibrand.blogspot.in

http://wikibrand.blogspot.in
http://wikibrand.blogspot.in

http://wikibrand.blogspot.in
http://wikibrand.blogspot.in
http://wikibrand.blogspot.in

RESULT:
            Thus a table is created and the details are entered into the table using jdbc from the registration form successfully.
SOURCE:PVPSIT FOR JNTU

40 comments:

  1. perfect explanation about java programming .its very useful.thanks for your valuable information.dot net training center in chennai | java training in velachery

    ReplyDelete
  2. Thanks a lot! You made a new blog entry to answer my question; I really appreciate your time and effort.java training in chennai | chennai's no.1 java training in chennai

    ReplyDelete
  3. Nice blog it's very helpful information. Thanks for sharing. keep sharing such
    informative Ideas
    extract phone numbers
    from website

    ReplyDelete
  4. Thanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging


    Hadoop Training in Chennai

    Aws Training in Chennai

    Selenium Training in Chennai

    ReplyDelete
  5. A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.

    python online training
    python training in chennai

    ReplyDelete
  6. Read all the information that i've given in above article. It'll give u the whole idea about it.
    java training in tambaram | java training in velachery

    java training in omr | oracle training in chennai

    ReplyDelete
  7. Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me 
    python training in chennai
    python training in chennai
    python training in Bangalore

    ReplyDelete
  8. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.


    angularjs Training in chennai
    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    ReplyDelete
  9. Good Post, I am a big believer in posting comments on sites to let the blog writers know that they ve added something advantageous to the world wide web.

    Data science course in tambaram | Data Science course in anna nagar
    Data Science course in chennai | Data science course in Bangalore
    Data Science course in marathahalli | Data Science course in btm

    ReplyDelete

  10. Howdy, would you mind letting me know which web host you’re utilizing? I’ve loaded your blog in 3 completely different web browsers, and I must say this blog loads a lot quicker than most. Can you suggest a good internet hosting provider at a reasonable price?
    Amazon Web Services Training in OMR , Chennai | Best AWS Training in OMR,Chennai
    Amazon Web Services Training in Tambaram, Chennai|Best AWS Training in Tambaram, Chennai

    ReplyDelete
  11. Thank you for sharing such great information with us. I really appreciate everything that you’ve done here and am glad to know that you really care about the world that we live in

    angularjs online Training

    angularjs Training in marathahalli

    angularjs interview questions and answers

    angularjs Training in bangalore

    angularjs Training in bangalore

    ReplyDelete
  12. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
    Data Science Training in Chennai | Data Science Course in Chennai
    Python Course in Chennai | Python Training Course Institutes in Chennai
    RPA Training in Chennai | RPA Training in Chennai

    ReplyDelete

  13. Thanks for sharing such a valuable information. The context has been explained really well. Follow us for more Info on Data Science at Data Science Training In Hyderabad

    ReplyDelete
  14. I would like to share the informative contents with my office circle...Really the contents of the blogs are creating a good opportunities...Keep posting
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

    ReplyDelete

  15. Great Article
    Cloud Computing Projects


    Networking Projects

    Final Year Projects for CSE


    JavaScript Training in Chennai

    JavaScript Training in Chennai

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

    ReplyDelete
  16. It is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. It is really explainable very well and i got more information from your blog. Please, continue to give me such valuable posts.Data Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training

    ReplyDelete
  17. This article gives more useful information to me. Great post .Thanks for sharing useful information. oracle training in chennai

    ReplyDelete
  18. This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information.
    Java Training in Chennai

    Java Training in Velachery

    Java Training in Tambaram

    Java Training in Porur

    Java Training in OMR

    Java Training in Annanagar


    ReplyDelete
  19. If Big Data is a job that you're dreaming of, then we, Infycle are with you to make your dream into reality. Infycle Technologies offers the best Big Data Course Chennai, with various levels of highly demanded software courses such as Java, Python, Hadoop, AWS, etc., in 100% hands-on practical training with specialized tutors in the field. Along with that, the pre-interviews will be given for the candidates, so that, they can face the interviews with complete knowledge. To know more, dial 7502633633 for more.

    https://infycletechnologies.com/big-data-training-in-chennai/

    ReplyDelete
  20. Title:
    Top Oracle DBA Training in Chennai | Infycle Technologies

    Description:
    Want to learn Oracle DBA along with the job opportunities? Infycle are with you to make your dream into reality. Infycle Technologies gives the most trustworthy Oracle DBA Training in Chennai, in 100% hands-on practical training with professional tutors in the field. Along with that, the mock interviews will be assigned for the candidates, so that, they can meet the job interviews with full confidence. To transform your career to next level, call 7502633633 to Infycle Technologies and grab a free demo to know more
    Top training Institute in Chennai

    ReplyDelete

  21. Thanks for posting the best information and the blog is very important.

    Visit us: Java Online Training Hyderabad
    Visit us: Core Java Online Course
    Visit us: java course

    ReplyDelete
  22. Great blog found to be well written in a simple manner that everyone will understand and gain the enough knowledge from your blog

    AWS Training in Hyderabad

    ReplyDelete
  23. Did you want to set your career towards Big Data? Then Infycle is with you to make this into reality. Infycle Technologies gives the combined and best Big Data Hadoop Training in Chennai, in 100% hands-on training guided by specialized trainers in the field. In addition to this, the mock interviews will be given to the candidates, so that they can face the interviews with complete confidence. Apart from all, the candidates will be placed in the top MNC's with a great salary package. To get it all, call 7502633633 and make this happen for your happy life.

    BEST TRAINING IN CHENNAI

    ReplyDelete
  24. Grab the Digital Marketing Training in Chennai from Infycle Technologies, the best software training institute, and Placement center in Chennai which is providing professional software courses such as Data Science, Artificial Intelligence, Cyber Security, Big Data, Java, Hadoop, Selenium, Android, and iOS Development, DevOps, Oracle etc with 100% hands-on practical training. Dial 7502633633 to get more info and a free demo and to grab the certification for having a peak rise in your career.

    ReplyDelete
  25. I want to say thanks to you. I have bookmark your site for future updates.
    data scientist certification malaysia

    ReplyDelete
  26. If salary is your only income means. Simply think to make it HIGH by getting into AWS training institute in Chennai, Infycle. It will be so easier for you because, past 15 years software industry Infycle leads a 1 place for giving a best students in IT industry.

    ReplyDelete
  27. Finish the Selenium Training in Chennai from Infycle Technologies, No.1 software training institute in Chennai which is providing professional courses for students, freshers, experienced, and tech professionals. We provide courses like DevOps, Artificial Intelligence, Cyber Security, Python, Oracle, Java, Power BI, Digital Marketing, Data Science, etc. with the best trainers receiving amazing training for the best career. For more details and demo classes call 7504633633.

    ReplyDelete
  28. Very awesome blog. Great stuff. Informative content. Very useful to many people. Keep up this good work.
    Data Science Training and Placements in Hyderabad

    ReplyDelete
  29. I have read your excellent post. This is a great job. I have enjoyed reading your post first time. I want to say thanks for this post. Thank you... business analytics course in mysore

    ReplyDelete
  30. In the wake of perusing your article, I was astounded. I realize that you clarify it well overall. What's more, I trust that different perusers will likewise encounter how I feel in the wake of perusing your article.
    data science institutes in hyderabad

    ReplyDelete
  31. Great info! I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have.
    cyber security course in malaysia

    ReplyDelete
  32. Excellent information! I just discovered your site and have been following along. I intended to post my initial comment. The only thing I can say is that I have. customer relationship management in erp

    ReplyDelete

 

Sample text

Sample Text

Sample Text