1 Replies - 1645 Views - Last Post: 13 October 2012 - 04:17 AM Rate Topic: -----

#1 HemalathaGopalTmr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 13-October 12

insert data to database

Posted 13 October 2012 - 01:24 AM

String name=request.getParameter("Cname");
String password=request.getParameter("pass");
String DOB=request.getParameter("DOB");
String HQ=request.getParameter("dropdown");
String HA=request.getParameter("HA");
String Photo=request.getParameter("Photo");

try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Con=DriverManager.getConnection("jdbc:mysql://localhost:3306/CMS","root","root");
pst=Con.prepareStatement("insert into Customer(CustName,Password,DOB,HQ,HA,Image)values(?,?,?,?,?,?)");



pst.setString(1, name);
pst.setString(2, password);
pst.setString(3, DOB);
pst.setString(4, HQ);
pst.setString(5, HA);
pst.setString(6, Photo);

This is my Code I dont Have Errors. But It Doesnt Insert into Database.

Is This A Good Question/Topic? 0
  • +

Replies To: insert data to database

#2 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1423
  • View blog
  • Posts: 3,165
  • Joined: 05-April 11

Re: insert data to database

Posted 13 October 2012 - 04:17 AM

You never execute the SQL statement

Call executeUpdate() on your prepared statement to insert the record :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1