0

i am using jdbc driver library to connect my android app to sql server 2014.it gives me error sometimes while executing query.Error is mention below

cannot open database requested by the login. the login failed for user

Here is code for connecting android app to sql server 2014

String connectionURL;
    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        connectionURL = "jdbc:jtds:sqlserver://"
                + user.getServerIP()
                + ";databaseName="
                + user.getDbName()
                + ";user="
                + user.getUserName()
                + ";password="
                + user.getPassword()
                + ";";
        Connection con = DriverManager.getConnection(connectionURL);
        con.close();
        return con;
    } catch (Exception e) {
        Timber.e(e.getMessage());
        return null;
    }

Please help me out.

Sagar
  • 585
  • 1
  • 9
  • 28
  • You should not connect directly to a database server using a JDBC driver. See also [Can we connect remote MySQL database in Android using JDBC?](https://stackoverflow.com/questions/26470117/can-we-connect-remote-mysql-database-in-android-using-jdbc) – Mark Rotteveel Sep 18 '19 at 14:07
  • according to requirement all the database is in offline mode so i need to connect android app using local wifi – Sagar Sep 19 '19 at 08:16
  • How can the database be in an 'offline' mode, when it is a remote database? – Mark Rotteveel Sep 19 '19 at 09:12
  • sql server is installed on local pc in shop and i am connecting it with local wifi using local pc IP address – Sagar Sep 20 '19 at 13:02

0 Answers0