0

Can you help me, please? I'm trying to create an Android app, which will connect to SQL Server Database. I'm using JDBC driver and:

  1. Added JDBC in Projects Setting -> Library (shown in External Libraries)
  2. The code of connecting to DB is as follows:

    try {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        String url = "jdbc:sqlserver://xxx.x.x.x:yyyy;integratedSecurity=true;"
        con = DriverManager.getConnection(url);
        if (con != null) {
            tv.setText("Connected");
        } else {
            tv.setText("Not connected");
        } catch (Exception ex) {
        tv.setText("" + ex);
    }
    

Eventually, I receive an Exception, that Driver com.microsoft.jdbc.SQLServerDriver not found

If I run the same Console app on Java app, it works.

5
  • did you install SQL Server Database in your android?wow Commented Nov 1, 2017 at 6:04
  • see stackoverflow.com/questions/16851938/… Commented Nov 1, 2017 at 6:08
  • No. Actually, I plan Android app to connect to a SQL Server, that is on my home computer Commented Nov 1, 2017 at 6:09
  • 1
    then you dont need driver in your android app, just make a web service Commented Nov 1, 2017 at 6:16
  • Can you please clarify a bit Commented Nov 1, 2017 at 6:28

1 Answer 1

1

The proper way is add rest api at home server and use on phone to connect and exchange data. Its not enterprise java and it wouldn't work properly.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much! The trouble was, I didn't add jdbc library in the project properly. The next problem I faced is that network connection goes via main thread. So I need to create a separate thread for SQL Server connection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.