2
I put the jar and made the build path . I’ve been trying for a while to connect with the microsoft bank but gives this error:
Exception in thread "main" java.lang.RuntimeException: com.microsoft.sqlserver.jdbc.SQLServerException: Falha na conexão TCP/IP com o host localhost, porta 1433. Erro: "Connection refused: connect. Verifique as propriedades da conexão. Verifique se uma instância do SQL Server está sendo executada no host e se está aceitando conexões TCP/IP na porta. Verifique se as conexões TCP na porta não foram bloqueadas por um firewall.".
at br.com.caelum.jdbc.ConnectionFactory.getConnection(ConnectionFactory.java:16)
at DAO.ContatoDAO.<init>(ContatoDAO.java:16)
at br.com.caelum.jdbc.teste.TestaConexao.main(TestaConexao.java:22)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Falha na conexão TCP/IP com o host localhost, porta 1433. Erro: "Connection refused: connect. Verifique as propriedades da conexão. Verifique se uma instância do SQL Server está sendo executada no host e se está aceitando conexões TCP/IP na porta. Verifique se as conexões TCP na porta não foram bloqueadas por um firewall.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:241)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2243)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:491)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1309)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at br.com.caelum.jdbc.ConnectionFactory.getConnection(ConnectionFactory.java:14)
... 2 more
The Connectionfactory class
package br.com.caelum.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectionFactory {
private String conexao = "jdbc:sqlserver://localhost:1433;databaseName=fj21";
public Connection getConnection(){
try {
return DriverManager.getConnection(conexao, "sa","");
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
I tweaked the database server settings and left tcp enabled.
Did you install this SQL? As far as I know SQL does not allow blank password for SA
– Krismorte
@Krismorte can disable the "password policy", there is nothing else in it, besides that her problem is with generating the connection, the bank does not even respond.
– DH.
I installed with password yes @Krismorte removed pq was kind of beast password...
– Aline
Have you disabled the firewall? Or added the port in the 1433 list as an exception?
– Krismorte
It wasn’t the firewall, no. It was the same connection string...
– Aline
Before asking the question I included port 1433 yes, there on tcp/ip...that wasn’t it.
– Aline
Aline, when you find the solution to your question yourself, you can post it as an answer right below. I suggest you edit the question by removing the answer, and post as the answer normally, so it conforms to the rules of the site.
– user28595