Menu

connect to sql server 2012 in android with jTDS 1.3.1

2015-11-01
2015-11-03
  • Alireza Azadi

    Alireza Azadi - 2015-11-01

    Hi all,
    Previously i connnect to SQL server 2005 with jTDS 1.3.0 and everything was OK.
    Now i want to connect to SQL server 2012 with jTDS 1.3.1.
    I have this ConnectionUrl, but i can not connect.
    I tried different solutions.

           setConnectionURL("jdbc:jtds:sqlserver://" + getIpAddress() + "/" + getDb() + ";instance=MSSQLSERVER"+ "," + getUserName()
                        + "," + getPassword());
    

    Could you please help me?

     
  • Bernd Eckenfels

    Bernd Eckenfels - 2015-11-01

    Hard to say without any error message or other diagnostics, but I strongly suspect your new SQLServer has the SQL Browser service disabled or firewalled. In this case it cannot find the port of the SQL Server instance by instance name. You will have to add a ":port" to the URL after the IP address. The (semi dynamic selected) port can be seen in the SQL Server configuration manager, it is normally not 1433.

     
    • Alireza Azadi

      Alireza Azadi - 2015-11-03

      @Berned Eckenfels:
      Thx for reply.
      Look, i have a ConnectionHelper class that Connection String is there,And in the other hand,in my main Activity,in onCreate method i made a new instance of ConnectionHelper and get its Connection to a CallableStatement,
      Here is this :

                   CallableStatement callableStatement = null;
                   ConnectionHelper conn = new ConnectionHelper();
                   callableStatement = conn.getConnection().prepareCall("{CALL SpGetAllStatus}");
      

      I got NullPointExection in the line that i call prepareCall method, and As you know better,we got this when we call a method from null object,that means my ConnectionHelper object is null, and its null,cause it could not connect to the SQL Server.( Am i right? ) and it could not connect,cause of my Connection String.
      All ports listen to 1433.

       
  • Alireza Azadi

    Alireza Azadi - 2015-11-03

    @Berned Eckenfels : Can SQL Server 2012 collation effect on connecting to DB via jTDS?

     

    Last edit: Alireza Azadi 2015-11-05

Log in to post a comment.