2

I am trying to update particular row in ms access table. I have updated data in ms access by using this query "update simba SET Username=?,Password=?"this will update the whole table in ms access,but i am trying to update a particular row and for updating a particular column i used this query in my code String sql="update simba SET Username=?,Password=? Where Username='"+name1+"'and Password='"+pass1"'";but it's giving me this error ";" expected.

Here is my code:

Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection con=DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\MUHAMMAD SHAHAB\\real estate.accdb");
String name=fit.getText();
String pass=String.valueOf(dis.getPassword());
String name1=vis.getText();
String pass1=String.valueOf(viss.getPassword());
String sql="update simba SET Username=?,Password=? Where Username='"+name1+"'and Password='"+pass1"'";
PreparedStatement pst=con.prepareStatement(sql);
pst.setString(1,name);
pst.setString(2,pass);

What am i doing wrong?

1 Answer 1

2
String sql = "..." + pass1 + "'";
                           ^

You missed the plus sign in the end of a String literal assigned to your sql variable.

Sign up to request clarification or add additional context in comments.

1 Comment

Oops how can i forget this.Now it's working after putting "+" sign at the end of pass1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.