Search Results

Search found 3 results on 1 pages for 'shino88'.

Page 1/1 | 1 

  • HTTP client - HTTP 405 error "Method not allowed". I send a HTTP Post but for some reason HTTP Get i

    - by Shino88
    Hey I am using apache library. I have created a class which sends a post request to a servlet. I have set up the parameters for the client and i have created a HTTP post object to be sent but for some reason when i excute the request i get a reposnse that says the get method is not supported(which is true cause i have only made a dopost method in my servlet). It seems that a get request is being sent but i dont know why. The post method worked before but i started gettng http error 417 "Expectation Failed" which i fixed by adding paramenters. below is my class with the post method. P.s i am developing for android. public class HTTPrequestHelper { private final ResponseHandler<String> responseHandler; private static final String CLASSTAG = HTTPrequestHelper.class.getSimpleName(); private static final DefaultHttpClient client; static{ HttpParams params = new BasicHttpParams(); params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, HTTP.UTF_8); ///params.setParameter(CoreProtocolPNames.USER_AGENT, "Android-x"); params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 15000); params.setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register( new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); schemeRegistry.register( new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); client = new DefaultHttpClient(cm,params); } public HTTPrequestHelper(ResponseHandler<String> responseHandler) { this.responseHandler = responseHandler; } public void performrequest(String url, String para) { HttpPost post = new HttpPost(url); StringEntity parameters; try { parameters = new StringEntity(para); post.setEntity(parameters); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } BasicHttpResponse errorResponse = new BasicHttpResponse( new ProtocolVersion("HTTP_ERROR", 1, 1), 500, "ERROR"); try { client.execute(post, this.responseHandler); } catch (Exception e) { errorResponse.setReasonPhrase(e.getMessage()); try { this.responseHandler.handleResponse(errorResponse); } catch (Exception ex) { Log.e( "ouch", "!!! IOException " + ex.getMessage() ); } } } I tried added the allow header to the request but that did not work as well but im not sure if i was doing right. below is the code. client.addRequestInterceptor(new HttpRequestInterceptor() { @Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException { //request.addHeader("Allow", "POST"); } });

    Read the article

  • Killing Mysql prcoesses staying in sleep command.

    - by Shino88
    Hey I am connecting a MYSQL database through hibernate and i seem to have processes that are not being killed after they are finished in the session. I have called flush and close on each session but when i check the server the last processes are still there with a sleep command. This is a new problem which i am having and was not the case yesterday. Is there any way i can ensure the killng of theses processes when i am done with a session. Below is an example of one of my classes. public JSONObject check() { //creates a new session needed to add elements to a database Session session = null; //holds the result of the check in the database JSONObject check = new JSONObject(); try{ //creates a new session needed to add elements to a database SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session = sessionFactory.openSession(); if (justusername){ //query created to select a username from user table String hquery = "Select username from User user Where username = ? "; //query created Query query = session.createQuery(hquery); //sets the username of the query the values JSONObject contents query.setString(0, username); // executes query and adds username string variable String user = (String) query.uniqueResult(); //checks to see if result is found (null if not found) if (user == null) { //adds false to Jobject if not found check.put("indatabase", "false"); } else { check.put("indatabase", "true"); } //adds check to Jobject to say just to check username check.put("justusername", true); } else { //query created to select a username and password from user table String hquery = "Select username from User user Where username = :user and password = :pass "; Query query = session.createQuery(hquery); query.setString("user", username); query.setString("pass", password); String user = (String) query.uniqueResult(); if(user ==null) { check.put("indatabase", false); } else { check.put("indatabase", true); } check.put("justusername", false); } }catch(Exception e){ System.out.println(e.getMessage()); //logg.log(Level.WARNING, " Exception", e.getMessage()); }finally{ // Actual contact insertion will happen at this step session.flush(); session.close(); } //returns Jobject return check; }

    Read the article

  • Killing Mysql processes staying in sleep command.

    - by Shino88
    Hey I am connecting a MYSQL database through hibernate and i seem to have processes that are not being killed after they are finished in the session. I have called flush and close on each session but when i check the server the last processes are still there with a sleep command. This is a new problem which i am having and was not the case yesterday. Is there any way i can ensure the killng of theses processes when i am done with a session. Below is an example of one of my classes. public JSONObject check() { //creates a new session needed to add elements to a database Session session = null; //holds the result of the check in the database JSONObject check = new JSONObject(); try{ //creates a new session needed to add elements to a database SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session = sessionFactory.openSession(); if (justusername){ //query created to select a username from user table String hquery = "Select username from User user Where username = ? "; //query created Query query = session.createQuery(hquery); //sets the username of the query the values JSONObject contents query.setString(0, username); // executes query and adds username string variable String user = (String) query.uniqueResult(); //checks to see if result is found (null if not found) if (user == null) { //adds false to Jobject if not found check.put("indatabase", "false"); } else { check.put("indatabase", "true"); } //adds check to Jobject to say just to check username check.put("justusername", true); } else { //query created to select a username and password from user table String hquery = "Select username from User user Where username = :user and password = :pass "; Query query = session.createQuery(hquery); query.setString("user", username); query.setString("pass", password); String user = (String) query.uniqueResult(); if(user ==null) { check.put("indatabase", false); } else { check.put("indatabase", true); } check.put("justusername", false); } }catch(Exception e){ System.out.println(e.getMessage()); //logg.log(Level.WARNING, " Exception", e.getMessage()); }finally{ // Actual contact insertion will happen at this step session.flush(); session.close(); } //returns Jobject return check; }

    Read the article

1