Connecting to Azure SQL DB via JTDS on an Android

2019-07-15 09:44发布

问题:

I'm using JTDS 1.2.7 to connect my Android app to a Windows Azure SQL Server.

Source code:

String connectionString = 
"jdbc:jtds:sqlserver://SERVER.database.windows.net:1433;database=demo;" +
"user=test@SERVER;password=PASSWORD;ssl=require";
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection con = DriverManager.getConnection(connectionString);
Statement st = con.createStatement();
res=st.executeQuery(sql);

When I try to connect to the database I get the java.lang.NoClassDefError: com.sun.net.ssl.SSLContext exception. I tried to add jsse.jar to my build path, but the app just shuts down instead of making connection. What am I doing wrong?