Aleksandr
Aleksandr

Reputation: 11

Connect to SQL Server Database using jdbc Java, Android app

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.

Upvotes: 0

Views: 794

Answers (1)

Mykola Tychyna
Mykola Tychyna

Reputation: 171

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.

Upvotes: 1

Related Questions