conxion DB on android with MSSQL auth

0

I'm trying to connect to a BD from an Android device, but the DB is in MSSQL with windows authentication through a VPN. Download to the device the Sonicwall app which connects me to the VPN but when running the project I have this error: java.sql.SQLException: I/O Error: DB server closed connection. . in some post I read that this can not be done, it only works in windows. I appreciate your time and answers to this matter.

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        String cn = "jdbc:jtds:sqlserver://ip:port/DBname;instance=INSTANCIA_SQL;user=username;password=secret;";
        connection = DriverManager.getConnection(cn);
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from table");
        while (resultSet.next()){
            Log.i("primer campo",resultSet.getString(1));
        }

    } catch (ClassNotFoundException e) {
        e.printStackTrace();

    } catch (SQLException e) {
        e.printStackTrace();

    }
    
asked by Arnold agcaballerma Caballero 07.02.2018 в 04:35
source

0 answers