jeudi 27 décembre 2018

Connect JDBC in maven web project on eclipse

I'm trying to connect my MAVEN WEB PROJECT to MSSQLServer using jdbc connection string, my project is already connected to a PostgreSQL data source by the web server. :

this is my code

Connection con;
try{DriverManager.registerDriver(new SQLServerDriver());}
catch(SQLException e){e.printStackTrace()}
String url="jdbc:sqlserver://SERVER\\INSTANCE:1433;DatabaseName=myDatabase";
String userName = "user";
String userPass = "123456";
try{con = DriverManager.getConnection(url ,userName , userPass);}
catch(SQLException e){e.printStackTrace()}


and exception shows: The TCP/IP connection the the host SERVER, port 1433 has failed. Error: "connect timed out. verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port.

The Network services for the SQL server are runing on the server and the port is set to 1433, and it is added to the firewall allowed ports

I've tried the same code in a regular java project and it works perfectly.




Aucun commentaire:

Enregistrer un commentaire