java - Why am i getting an illegal character error on an sql query? -


the error states index of illegal character 6 6th character space after select

    static final string jdbc_driver = "com.mysql.jdbc.driver"; static final string db_url = "jdbc:mysql://sql3.freemysqlhosting.net:3306/";  static final string user = "****"; static final string pass = "****";  public jsonarray getlocation(arraylist postparameters) {     connection conn = null;     httpentity httpentity = null;     try{          class.forname(jdbc_driver);          system.out.println("connecting ");         conn = drivermanager.getconnection(db_url, user, pass);         system.out.println("connection successful.");          string sql = "select * locations loctag '%"+postparameters+"%'";          defaulthttpclient httpclient = new defaulthttpclient();          httppost httppost = new httppost(sql);         httppost.setentity(new urlencodedformentity(postparameters,"utf-8"));         httpresponse httpresponse = httpclient.execute(httppost);         httpentity = httpresponse.getentity(); 

i getting

java.lang.illegalargumentexception: illegal character in path @ index 6: select * locations loctag = '%[loctag=fast]%' 

i have tried encoding no luck.

you trying execute sql query http request. makes no sense @ all. httppost constructor expects uri, select statement not uri.

you either need use jdbc execute query, or need or post uri. can't tell code trying though.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -