0

Am trying to connect to MSSQL database from Android Studio.

My code:

Class.forName("net.sourceforge.jtds.jdbc.Driver");
StrictMode.ThreadPolicy policy = new   StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection conn = DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.1.66;databasename=POSEIDON;username=sa;password=myPass");

When making the query i receive:

 W/System.err: java.sql.SQLException: Single-Sign-On is only supported on Windows. Please specify a user name.
Alex E.
  • 139
  • 3
  • 14
  • consider developing web services at back-end and on android side connecting these web services using http. It is the common way. Connecting to SqlServer from Android is not suggested. [link](https://stackoverflow.com/questions/3492417/connect-to-sql-server-from-android?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa) – Fer Apr 19 '18 at 09:21
  • It is too much work for the current project. It's not a commercial app, it's only for internal use. – Alex E. Apr 19 '18 at 09:26
  • Possibly duplicate with this: https://stackoverflow.com/questions/12375437/java-sql-sqlexception-single-sign-on-is-only-supported-on-windows-please-speci – Cao Minh Vu Apr 19 '18 at 09:38
  • It mostly is, but i dont understand the answer. – Alex E. Apr 19 '18 at 09:49
  • I worked it out. This explains it : https://stackoverflow.com/questions/3682852/sql-server-connect-with-windows-authentication . – Alex E. Apr 19 '18 at 11:27

1 Answers1

0

Access MSSQL database direct from Andriod it's not the right way . but something like an API (RESTFull , SOAP ) through which the records are queried and passed to the Android .

If you need to save date on database , SQLite is one way of storing app data .Its stores data to a text file on a device you don't need to establish any kind of connections for it like JDBC,ODBC e.t.c.

Below is tutorial on use SQLite:-

Save Data using SQLite

Al-Mustafa Azhari
  • 850
  • 1
  • 9
  • 24
  • I actually am using MS SQL. I only read from the database, i don't store anything. Also, the project is not that big to develop a backend webservice. As you can see in the code i use the jdbc:jtds library. – Alex E. Apr 19 '18 at 09:48
  • Try to use the user/password of Windows OS that you run the database in instead of the usual SQL Server authentication . – Al-Mustafa Azhari Apr 19 '18 at 10:07
  • I tried with my user, and i use both types of auth , integrated and Windows auth. It gives me the same error. I tried domain\\username. – Alex E. Apr 19 '18 at 10:45