Ruchit bajwa 0 Newbie Poster

hello,i am using MS-access db and java code.i want to insert values in a particular row based on selected serial no. and i use statement

try
		{		
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		Connection con2=DriverManager.getConnection("jdbc:odbc:ResumeDSN");
		Statement stat1=con2.createStatement();
		Statement stat2=con2.createStatement();
		stu = new Student();
					
		String Fir6=pers.tname.getText();
		if(Fir6.equals("")==true){Fir6=" ";}
		String Sec6=pers.tdob.getText();
		if(Sec6.equals("")==true){Sec6=" ";}
		String Thir6=pers.tfather.getText();
		if(Thir6.equals("")==true){Thir6=" ";}
		String Four6=pers.tcontct.getText();
		if(Four6.equals("")==true){Four6=" ";}
		
		String Fir7=pers.temailid.getText();
		if(Fir7.equals("")==true){Fir7=" ";}
		String Sec7=pers.taddr.getText();
		if(Sec7.equals("")==true){Sec7=" ";}
		String Thir7=pers.cgen.getSelectedItem();
		if(Thir7.equals("")==true){Thir7=" ";}
		String Four7=pers.clanguages.getSelectedItem();
		if(Four7.equals("")==true){Four7=" ";}
		String sq = "Select name,dob,father,contactno,emailid,address,gender,language from PersonalDetails where pID = 1001 ";
		ResultSet s =stat1.executeQuery(sq);
		if(s != null)
		{
				
		 String sql1 = "insert into PersonalDetails(name,dob,father,contactno,emailid,address,gender,language) values('"+Fir6+"','"+Sec6+"','"+Thir6+"','"+Four6+"','"+Fir7+"','"+Sec7+"','"+Thir7+"','"+Four7+"')";
		 int nr3=stat2.executeUpdate(sql1);
			if (nr3>0)
			{
				JOptionPane.showMessageDialog(this,"YOUR PersonalDetails SAVED SUCCESSFULLY !!!","",JOptionPane.PLAIN_MESSAGE);  
				//this.dispose();
			}
		}
		else
		{
			JOptionPane.showMessageDialog(this,"failed !!!","",JOptionPane.PLAIN_MESSAGE);  
		}
		con2.close();
		}
		catch (Exception ex)
		{
			JOptionPane.showMessageDialog(this,"Access Denied !!!","",JOptionPane.PLAIN_MESSAGE);  
				ex.printStackTrace();
		}

i dont find values inserted in table..and dont have any error..so plz tell me how can i insert values in a selected row in the table.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.