How can i connect to sql server from my android application?
11,840
You have to add the following permission to your application manifest file.
<manifest>
.....
<uses-permission android:name="android.permission.INTERNET" />
.....
</manifest>
Author by
ugurrrrr
Updated on June 05, 2022Comments
-
ugurrrrr almost 2 years
I'm developing an android application. I need connect to sql server. I wrote a code for test connection but i get this error :
java.sql.SQLException: Network error IOException: Permission denied
- I checked connection string.
- I closed firewall for 1433.
- I tried configured Sql Server tcp and remote access settings
but i still get the same error. What is my mistake?
My environment:
- Sql Server 2008 R2
- Eclipse
- jtds
My Code is:
try { Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance(); **Connection conn=DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.1.33:1433/Android_Deneme;instance=CASPER\\MORTY;user=ugur;password=1234");** String sql="insert into tablo1(ad,yas) values(?,?)"; PreparedStatement prepared = conn.prepareStatement(sql); prepared.setString(1, "ali"); prepared.setInt(2, 30); prepared.executeUpdate(); } catch(Exception e) { e.printStackTrace(); }
-
ugurrrrr over 12 yearsThank you i did this but now i get this error: java.sql.SQLException: Network error IOException: /192.168.1.33:1433 Connection refused
-
havexz over 12 yearsyou getting network error again? Can you put ur sql statement?
-
ugurrrrr over 12 yearsYes i'm getting network error again. There is a Sql State on the error line. It is : 08S01 Is that what you want?
-
havexz over 12 yearsAre you trying to connect over the wifi? If so check that your phone is also on the wifi network. Or it could be firewall issue. so it is no more an android issue.
-
ugurrrrr over 12 yearsYes, over the wifi. I did these things already. I connect the phone on the network. I closed firewall but i still get the same error. I think the problem is about sql server. I'm missing something about remote access but what. I coudn't find.
-
havexz over 12 yearsAre you able to ping the above address from some other machine?
-
ugurrrrr over 12 yearsYes, i can. I can also connect to sql server from another pc.
-
ugurrrrr over 12 yearsThank you for your help. I fixed the problem. The problem was about sql server configuration.