tags:

views:

47

answers:

3

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,

+3  A: 

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
but jdbc is not to use only over networking? So should I use jdbc over http?
Alex
A: 

I don't think there is any widely-used database driver based on HTTP. MySQL is not handling HTTP requests on port 3306. It's handling some specific protocol, that is implemented by the MySQL JDBC driver.

Donwload this driver, place it on your classpath, and obtain a Connection. Read about JDBC (Java DataBase Connectivity) and how to execute queries via Statements.

Bozho
+1  A: 

Ok, but how about this that says to

"never use a database driver across an Internet connection" link text

But they way .....I need from Android to mysql

Alex