1

My requirement is when I pass some paramenter query need to send object. not list.

I have written the code :

 public RDExecutive getExecutiveObject(String executivename){
     DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(this);
     dbAdapter.openDataBase();
     System.out.println( " ---- executivename --- " + executivename);
     String query="SELECT * FROM RDExecutive WHERE ExecutiveName = ?';";
     String[]d = new String[]{executivename};
     ArrayList stringList = dbAdapter.selectRecordsFromDBList(query, d);

     dbAdapter.close();

     ArrayList<Object> rdExecutiveObject = new ArrayList<Object>();
     RDExecutive rdExecutive = new RDExecutive();
     System.out.println( " -- stringList.size() -- " + stringList.size());

     for (int i = 0; i < stringList.size(); i++) {
        ArrayList<Object> arrayList2 = (ArrayList<Object>) stringList.get(i);
        ArrayList<Object> arrayList = arrayList2;
        ArrayList<Object> list = arrayList;

        try {
            rdExecutive.setBusinessUnit((String) list.get(0));
            rdExecutive.setExecutiveCode((String) list.get(1));
            rdExecutive.setExecutiveName((String) list.get(2));
            rdExecutive.setTerritoryCode((String) list.get(10));

        } catch (Exception e) {
            Log.i("***" + SalesRouteActivity.class.toString(), e.getMessage());
        }
        rdExecutiveObject.add(rdExecutive);
    }
    return rdExecutive;
}

This method is return RDExecutive object.

When I run this part , I got error

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xont.controller/com.xont.controller.DownlaodTableActivity}: 

android.database.sqlite.SQLiteException: unrecognized token: "';": , while compiling: 
SELECT * FROM RDExecutive WHERE ExecutiveName = ?';

How do we want to pass parameter to query.

2 Answers 2

1

You don't need the semicolong (";")

String query="SELECT * FROM RDExecutive WHERE ExecutiveName = ?'";

Should be fine

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

Comments

0

You have a SQL syntax error. You need to remove a single quote, i.e.

 // This line has the error:
 String query="SELECT * FROM RDExecutive WHERE ExecutiveName = ?';";

 // This is the same line with the error fixed:
 String query="SELECT * FROM RDExecutive WHERE ExecutiveName = ?;";

Comments

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.