kunal patra

kunal patra

  • NA
  • 7
  • 15.1k

My executeUpdate query can not work.....what is the problem

Aug 7 2013 3:27 AM
connect.jsp page code



<%@page import="java.sql.*" %>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:Kunal");
Statement st = conn.createStatement();
ResultSet rs=null;

%>







My Register.Jsp page Code...........


<%@include file="connect.jsp"%>
<%
String fname=request.getParameter("fname");
String mname=request.getParameter("mname");
String lname=request.getParameter("lname");
String uname=request.getParameter("uname");
String passw=request.getParameter("passw");
String email=request.getParameter("email");
String phno=request.getParameter("phno");
String address=request.getParameter("address");
String city="1";
String crno=request.getParameter("crno");
boolean valid=true;


st.executeUpdate("insert into credit(crno) values('"+crno+"')");
rs=st.executeQuery("select id from credit where crno='"+ crno +"'");
rs.next();
int crid=rs.getInt(1);
String sql="insert into Customer(fname,mname,lname,uname,passw,email,phno,address,cityid,crid) values(";
sql+="'"+fname+"','"+ mname+"','"+lname+"','"+uname+"','"+passw+"','"+email+"',"
+phno+",'"+address+"',"+city+","+crid+")";
//out.println(sql);
try{
st.executeUpdate(sql);%>
<h1>You Have registered successfully.Now you may login.</h1>
<%}
catch(Exception e){
System.out.println(e);
}
conn.close();
%>




the first two query works fine it will insert the data in the database but the third which is in the try block its not work ....please help ...if i write any thing wrong please give me proper solution....