Aaj
Aaj

Reputation: 259

JDBC on Android

I'm new to Android, and Java altogether for that matter and I'm having a heck of a time trying to connect my Android app to SQL Server 2005. I'm aware that the preferred way of dealing with data is via the consumption of a web service, but for my purposes I'm opting to connect via a direct SQL Connection. That said, I added the JDBC4 jar file to my project, and ensured that port 1433 was open on my sql server (I tested this using a windows desktop app as well as a windows mobile app I had handy), but for the life of me can't seem to get my android app to connect do to a permissions denied error:

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host
10.0.0.217, port 1433 has failed. Error: "Permission denied. Verify the connection   
properties. Make sure that an instance of SQL Server is running on the host and
accepting TCP/IP connections at the port. Make sure that TCP connections to the 
port are not blocked by a firewall.".

I'm using my sa username/password, which again I tested on a different platform, so I know conceptually at least, it should work. The following is the connection code I have in Eclipse:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
con = DriverManager.getConnection("jdbc:sqlserver://10.0.0.217;databaseName=star","sa","MyPassword");

Based on what I've been reading, everyone's solution was to add 1433 to their SQL configuration, but mine already is, and I also ensured the IP address was enabled. I'm at a loss but hoping that someone had a similar issue that turned up a solution.

Any help would be great. Thank you.

Upvotes: 0

Views: 2234

Answers (1)

Helper
Helper

Reputation: 91

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

Do you have that line in your android manifest file?

Upvotes: 1

Related Questions