Merci d'abord pour ta réponse,
Ensuite j'ai fait un code mais cela ne marche pas car il me dit
com.microsoft.sqlserver.jdbc.SQLServerException: Échec de l'ouverture de session de l'utilisateur 'admin'. L'utilisateur n'est pas associé à une connexion SQL Server approuvée.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at sdz1.main(sdz1.java:11)
Je pense qu'il faut que je mette un nom d'utilisateur et un mot de passe ou autre chose mais je travaille en local sur ma machine donc je ne sais pas...
VOilà mon code pour le moment :
import java.sql.*;
public class sdz1
{
public static void main(String[] args)
{
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("DRIVER OK ! ");
Connection cnx=DriverManager.getConnection("jdbc:sqlserver://localhost;database=test;user=admin;password=admin");
System.out.println("Connection effective !");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}