Jdbc et SQL server
adiaby
Messages postés
51
Date d'inscription
Statut
Membre
Dernière intervention
-
adiaby Messages postés 51 Date d'inscription Statut Membre Dernière intervention -
adiaby Messages postés 51 Date d'inscription Statut Membre Dernière intervention -
Bonjour,j'ai un programme java qui se connecte à une base de données SQL server avec un pilote jdbc (sqljdbc) dont le code est le suivant
import java.sql.*;
import java.io.*;
public class Testjdbc{
public static void main (String[] args)throws Exception{
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch(ClassNotFoundException e){
e.printStackTrace ();
}
String url="jdbc:sqlserver://localhost:1433;databaseName=ABC4";
Connection con=DriverManager.getConnection(url);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT id_item,type_item,type1_item,state,path,file FROM T_ITEM");
while (rs.next()){
int id=rs.getInt("id_item");
int type=rs.getInt("type_item");
int type1=rs.getInt("type1_item");
int etat=rs.getInt("state");
String chemin=rs.getString("path");
String nom=rs.getString("file");
System.out.println("le nom du fichier est: "+ nom);
}
}
}
Voici le message d'erreur:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: Connection refused: connect. Please verify the connection properties and check that a SQL Server instance is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:130)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1195)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(SQLServerConnection.java:1054)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:758)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at Testjdbc.main(Testjdbc.java:12)
j'ai besoin d'une astuce pour resoudre ce problème. Merci d'avance
import java.sql.*;
import java.io.*;
public class Testjdbc{
public static void main (String[] args)throws Exception{
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch(ClassNotFoundException e){
e.printStackTrace ();
}
String url="jdbc:sqlserver://localhost:1433;databaseName=ABC4";
Connection con=DriverManager.getConnection(url);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT id_item,type_item,type1_item,state,path,file FROM T_ITEM");
while (rs.next()){
int id=rs.getInt("id_item");
int type=rs.getInt("type_item");
int type1=rs.getInt("type1_item");
int etat=rs.getInt("state");
String chemin=rs.getString("path");
String nom=rs.getString("file");
System.out.println("le nom du fichier est: "+ nom);
}
}
}
Voici le message d'erreur:
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: Connection refused: connect. Please verify the connection properties and check that a SQL Server instance is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:130)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1195)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(SQLServerConnection.java:1054)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:758)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at Testjdbc.main(Testjdbc.java:12)
j'ai besoin d'une astuce pour resoudre ce problème. Merci d'avance
A voir également:
- Jdbc et SQL server
- Cybera server - Télécharger - Divers Réseau & Wi-Fi
- Ps3 media server - Télécharger - Divers Réseau & Wi-Fi
- Filezilla server - Télécharger - Téléchargement & Transfert
- Mysql community server - Télécharger - Bases de données
- Typsoft ftp server - Télécharger - Téléchargement & Transfert
1 réponse
TCP / IP activé?
http://www.devx.com/dbzone/Article/33681
http://www.devx.com/dbzone/Article/33681
adiaby
Messages postés
51
Date d'inscription
Statut
Membre
Dernière intervention
je ne sais pas. Comment vérifié si TCP/IP est activé.