Connecting to SQL Server 2014 from Android Studio

KonradK

I have a problem connecting to SQL-server database through from my android project. I have added sqljdbc41.jar file to my /app/libs directory and I have added it to dependencies in my android studio project.

I use following code:

package com.konrad.rezerwacje1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;



public class Database_Console {

public static void openConnection(){
    try {
        Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"‌​);
        String url = "jbdc:sqlserver://127.0.0.1:1433;databaseName=my_db";
        Connection con = DriverManager.getConnection(url);
    } catch (SQLException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

public static void main(String[] args){
    openConnection();
}
}

yet i still get this error

java.sql.SQLException: No suitable driver found for jbdc:sqlserver://127.0.0.1:1433;databaseName=my_db
    at java.sql.DriverManager.getConnection(DriverManager.java:689)
    at java.sql.DriverManager.getConnection(DriverManager.java:270)
YCF_L

Instead of this :

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"‌​);
String url = "jbdc:sqlserver://127.0.0.1:1433;databaseName=my_db";

You have to use this :

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://127.0.0.1:1433;DatabaseName=my_db";

Connection con = DriverManager.getConnection(url, "username", "password");

Note the different classname, and the fact that prefix jbdc in the URL has been changed to jdbc.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Connecting Access ADO to SQL Server 2014 Management Studio

From Dev

Connecting Android Studio to Web Service to SQL Server

From Dev

ColdFusion is not connecting datasource with SQL Server 2014

From Dev

Connecting python3 on Ubuntu to SQL Server 2014

From Dev

Connecting to SQL Server from Nodejs

From Dev

Connecting from Python to SQL Server

From Dev

Connecting to SQL Server from Nodejs

From Dev

Connecting to XMPP server from android

From Dev

Not able to deploy C# SQL CLR database project from Visual Studio 2010 to SQL Server 2014

From Dev

Missing SQL Server Management Studio in SQL Server 2014 Express

From Dev

SQL Server started, but SQL Server Management Studio not connecting to it

From Dev

Connecting to SQL Server 2008 R2 database from Visual Studio 2013

From Dev

Connecting android app to Microsoft SQL server 2008

From Dev

Connecting Xamarin.Android with SQL Server Database

From Dev

Accessing SQL Server from Batch File - not connecting

From Dev

Accessing SQL Server from Batch File - not connecting

From Dev

Connecting from local server to Android through internet

From Dev

Visual Studio 2013 does not create SQL Server 2014 LocalDB database

From Dev

Visual Studio 2013 incompatibility with MS SQL Server 2014

From Dev

SQL Server 2014 Management Studio won't remember custom color

From Dev

Visual Studio 2013 incompatibility with MS SQL Server 2014

From Dev

SQL server management studio 2014 setting only returns whole numbers

From Dev

User shortcuts setting in SQL Server Management Studio 2014?

From Dev

Connection String on Visual Studio 2013 with SQL Server 2014

From Dev

powershell script to automate installation of SQL Server 2014 management studio

From Dev

Connecting NetBeans 8.0.2 to Microsoft SQL Server Management Studio

From Dev

Unable to connect to Management Studio an "error occured while connecting to the SQL Server"

From Dev

NullReferenceException in SQL Server 2014

From Dev

Aggregation in SQL Server 2014

Related Related

  1. 1

    Connecting Access ADO to SQL Server 2014 Management Studio

  2. 2

    Connecting Android Studio to Web Service to SQL Server

  3. 3

    ColdFusion is not connecting datasource with SQL Server 2014

  4. 4

    Connecting python3 on Ubuntu to SQL Server 2014

  5. 5

    Connecting to SQL Server from Nodejs

  6. 6

    Connecting from Python to SQL Server

  7. 7

    Connecting to SQL Server from Nodejs

  8. 8

    Connecting to XMPP server from android

  9. 9

    Not able to deploy C# SQL CLR database project from Visual Studio 2010 to SQL Server 2014

  10. 10

    Missing SQL Server Management Studio in SQL Server 2014 Express

  11. 11

    SQL Server started, but SQL Server Management Studio not connecting to it

  12. 12

    Connecting to SQL Server 2008 R2 database from Visual Studio 2013

  13. 13

    Connecting android app to Microsoft SQL server 2008

  14. 14

    Connecting Xamarin.Android with SQL Server Database

  15. 15

    Accessing SQL Server from Batch File - not connecting

  16. 16

    Accessing SQL Server from Batch File - not connecting

  17. 17

    Connecting from local server to Android through internet

  18. 18

    Visual Studio 2013 does not create SQL Server 2014 LocalDB database

  19. 19

    Visual Studio 2013 incompatibility with MS SQL Server 2014

  20. 20

    SQL Server 2014 Management Studio won't remember custom color

  21. 21

    Visual Studio 2013 incompatibility with MS SQL Server 2014

  22. 22

    SQL server management studio 2014 setting only returns whole numbers

  23. 23

    User shortcuts setting in SQL Server Management Studio 2014?

  24. 24

    Connection String on Visual Studio 2013 with SQL Server 2014

  25. 25

    powershell script to automate installation of SQL Server 2014 management studio

  26. 26

    Connecting NetBeans 8.0.2 to Microsoft SQL Server Management Studio

  27. 27

    Unable to connect to Management Studio an "error occured while connecting to the SQL Server"

  28. 28

    NullReferenceException in SQL Server 2014

  29. 29

    Aggregation in SQL Server 2014

HotTag

Archive