Witajcie,
Chciałbym dodać do programu możliwość logowania za pomocą kont z poświadczeniem Windows. Logowanie ma odbyć się na podstawie kont w bazie MS SQL, konto dodałem do bazy i ustawiłem tryb logowania w bazie danych na autoryzacje windows. Przetestowałem proces logowania pod klientem Managment Studio. Chce dodać taką możliwość do programu w java, jednak mam problemy. Przy tworzeniu połączenia dodałem linijke: integratedSecurity, oraz dorzuciłem sql_auth.dll do katalogu programu. Jednak wywala mi błąd.
Co moge jeszcze poprawić?
Kod wygląda tak:
user="DOMENA\\login";
password="";
Connection connection = getConnectionWithWindowsLogin(user,password);
public static Connection getConnectionWithWindowsLogin(String user, String password) throws SQLException, Exception
{
BufferedReader reader = null;
String classpath = System.getProperty("java.class.path");
classpath = classpath.replace(classpath.substring(classpath.length()-7), "");
try{
reader = new BufferedReader(new InputStreamReader(new FileInputStream("config.txt"),"UTF-8"));
}
catch(Exception e){}
try{
reader = new BufferedReader(new InputStreamReader(new FileInputStream(classpath+"config.txt"),"UTF-8"));
}
catch(Exception e){}
String[] properties=new String[10];
String line = null;
int i=0,j=0;
while((line = reader.readLine())!=null)
{
if(i>0)
{
if(i%2!=0){
if((i==5)|(i==7))
{
properties[j]=Aes.decrypt(line);j++;
}
else{properties[j]=line;j++;}
}
}
i++;
}
//-------------------------------------------------------------------------
String databaseURL="jdbc:sqlserver:"+properties[0]+";databaseName="+properties[1]+";integratedSecurity=true";
System.out.println(databaseURL);
java.util.Properties props = new java.util.Properties();
props.put("user", user);
props.put("password",password);
props.put("charSet", properties[4]);
Connection connection = null;
connection = DriverManager.getConnection(databaseURL,props);
return connection;
}
Błąd krytyczny:
dbc:sqlserver://10.103.130.15;databaseName=MachineStops;integratedSecurity=true
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000561baf65, pid=4876, tid=5160
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b132) (build 1.8.0-b132)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# V [jvm.dll+0x12af65]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\OEE\OEE\hs_err_pid4876.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
dodanie znacznika <code> - furious programming