0

I've tried to connect to mysql using DefaultHttpClient, but so far no success. Error connection refused.

I can telnet MySQL using telnet 127.0.0.1 3306

enter code here

I'am using this example from apache website

DefaultHttpClient httpclient = new DefaultHttpClient();

httpclient.getCredentialsProvider().setCredentials(
                new AuthScope("localhost", 3306), 
                new UsernamePasswordCredentials("username", "password"));

        HttpGet httpget = new HttpGet("https://localhost:3306");

        System.out.println("executing request" + httpget.getRequestLine());
        HttpResponse response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();

enter code here

am I missing some concept for instance do I need a webserver or server side language like PHP?

I want to login, perform select, etc using http is that possible?

Regards,

Alex
  • 1
  • What language is this? (hint: add the tag, more users will answer). Also, unless the naming convention is wrong, it would be a weird setup that MySQL talks HTTP, it really doesn't out of the box. Enfin: usual MySQL suspect is: try `127.0.0.1` instead of `localhost`. – Wrikken Aug 05 '10 at 20:29

1 Answers1

4

DefaultHttpClient is for making connections to http servers, not to MySQL servers. Check out JDBC: http://java.sun.com/products/jdbc/overview.html

Scott Saunders
  • 29,840
  • 14
  • 57
  • 64