Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad

515 views

Published on

NicheTech is the best software company in Ahmedabad .

We are offering best software service in Ahmedabad.

We are also providing java training Ahmedabad .

NicheTech is helping in best java course Ahmedabad .

NicheTech helps you for java classes Ahmedabad .

WWW.LiveProjecttraining.in

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
515
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad

  1. 1. By: NicheTech http://www.nichetechinstitute.com/ ©NicheTech Computer Solutions Pvt ltd Demo Example for Insert records in Servlet
  2. 2. Login.jsp <html> <head> </head> <title>Login</title> <body> <form name="Login_form“ action=“Login" method="post"> User Name <input type="text" name="UserName" /> <br /> Password <input type="password" name=“pwd" /><br /> <input type="submit" name="sSubmit" value="Submit" /> </form> </body> </html>
  3. 3. connectivityClaas.java //Required import packages import java.io.*; import java.util.*; import javax.sql.*; import javax.servlet.*; import javax.servlet. Http.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement;
  4. 4. //class Nmae Declration  public class connectivityClaas extends HttpServlet  { // connecting to database object Connection cn = null; PreparedStatement pst try { Class.forName("com.mysql.jdbc.Driver"); con =DriverManager.getConnection (“localhost/Testexample", "root","root"); String username = req.getParameter(“UserName"); String fname = req.getParameter(“pwd"); stmt = con.createStatement(); String sql ="insert into login values (?,?)"; pst = connection.prepareStatement(sql); int numRowsChanged = pst.executeUpdate();
  5. 5. if(numRowsChanged==true) { out.println(“Successful Inserted”); }else { out.println(“Faild to Inserted”); } } catch (Exception){} }
  6. 6. Thanks  NicheTech Com Sol Pvt Ltd  Our Sites 1) http://www.nichetechsolutions.com/ (Development) 2) http://www.nichetechinstitute.com/ (NicheTech Gurukul) 3) http://www.liveprojecttraining.in/ ( Live Project Training Details) 4) https://www.facebook.com/nichetechinstituteIndi a ( For Daily Updates)

×