I have tried with java code to use Microsoft JDBC driver to get connection on SQL Instance enabled with SSL Protocal and SQL Server with NTLMV2 protocol.
I am using windows authentication to get connection which will take effect of both SSL and NTLMV2 protocols.
But the strange thing is we able to establish connection java JDBC client without setting java property for NTLMV2 and SSL as well.
Can some one help me out why this strange thing happened using Microsoft JDBC driver.
Please find my java code snippet which am using connection url to get connection with SQL Instance enabled with SSL and NTLMV2 protocols.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
public class SqlJdbcConnection
{
String dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String connectionUrl = "";
private void connect()
{
Connection conn=null;
Statement stmt=null;
ResultSet rset=null;
try
{
Class.forName(dbDriver);
}
catch (ClassNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
try
{
connectionUrl = "jdbc:sqlserver://192.168.11.215:1433;databaseName=master;integratedSecurity=true";
Properties infoProperties=new Properties();
infoProperties.put("UserName","administrator");
infoProperties.put("Password","abc098ABC");
infoProperties.put("domain","mas");
infoProperties.put("authenticationScheme","NTLM");
conn = DriverManager.getConnection(connectionUrl, infoProperties);
if(conn==null)
{
System.out.println("Connection is null");
return;
}
stmt=conn.createStatement();
rset = stmt.executeQuery("select @@version");
while(rset.next())
{
System.out.println(rset.getString(1));
}
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
if(rset!=null)
{
try
{
rset.close();
} catch (Exception e2) {
// TODO: handle exception
}
}
if(stmt!=null)
{
try
{
stmt.close();
} catch (Exception e2) {
// TODO: handle exception
}
}
if(conn!=null)
{
try
{
conn.close();
} catch (Exception e2) {
// TODO: handle exception
}
}
}
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
SqlJdbcConnection sqljdbc=new SqlJdbcConnection();
sqljdbc.connect(); }
}