RE6
RE6

Reputation: 2724

How to connect remote sql server database?


I have created a remote sql server 2005 database.
I need to get some data from it. How can I do this? I would be glad if you gave me the code and tell me where I need to insert each thing (like username, password, sever etc.)
Thank you and have a good day!
Ron

Upvotes: 2

Views: 11472

Answers (3)

Parth Doshi
Parth Doshi

Reputation: 4208

The most common way of connecting an Android application to a remote database like SQL Server 2005 or higher is to use Web Services.

There are loads of tutorials available for at your disposal. You can use and create a SOAP web service.

For starters, check this

If any problems please feel free to ask me, I have just recently completed a project on the same. I have used SQL Server 2008 as my database and Android as client

Cheers

Upvotes: 1

Jens Egholm
Jens Egholm

Reputation: 2710

I suggest you use the features of the standard library in the package java.sql. The DriverManager should have what you need. An example of a connection could look something like this (depending on what driver you use - replace the "com.mysql.jdbc.Driver" with the driver you need):

Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection(
                        "jdbc:mysql://insert_address_here/",
                        "user","password");
Statement statement   = connection.createStatement();
ResultSet result = statement.executeQuery(
     "SELECT * FROM sometable WHERE id = 1");

.. Just as an example. See more examples in java2s. Particularly under DriverManager and [ResultSet4.

Upvotes: 3

Mustafa Ekici
Mustafa Ekici

Reputation: 7470

I suggest you connect sql server using web services there is a lot tutorial on web.

Upvotes: 1

Related Questions