Good day.
The question is as follows:
There is sql server 2014. You need to connect to it from java-code (I work in the netbins).
I try this way:
String connectionString = "Data Source=servername;Initial Catalog=dbName;User id=user;Password=password;" Connection conn = DriverManager.getConnection(connectionString); The exception is poured:
java.sql.SQLException: No suitable driver found ...
The driver is in the lib folder of the project + I connect the driver directly in the code before the connection is established:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); If I use the query type string:
"jdbc:sqlserver://localhost:1433;user=name;password=password;database=dbName" That exception falls:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP / IP connection has failed. Error: "Connection refused: connect ...
In server services checked - all ports are included with values of 1433 ...
Already run out of ideas where to dig?
Help, pliz.
DriverManager.getConnectionmethod always accepts a jdbc url of the formjdbc:subprotocol:subname. Therefore, ODBC-shnaya connection string just does not fit. So you need to deal with the port. - Nofate ♦netstat -a -nin the console and show lines with port 1433. - Roman