I'm building an application from NetBeans IDE 8.1 and accessing the database developed in Sql server more when executing the application is generating the error:
Connection error The port number 1433 / system_vend is not valid
I already configured TCP / IP.
public class ConectaBanco {
public Statement stm;
public ResultSet rs;
private final String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private final String caminho = "jdbc:sqlserver://localhost:1433/sistema_venda";
private final String user = "user";
private final String senha = "password";
public Connection conn;
public void conexao(){
try {
System.setProperty("jdbc.Driver", driver);
conn = DriverManager.getConnection(caminho, user, senha);
JOptionPane.showMessageDialog(null, "Conectado com sucesso!");
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null,"Erro de conexao " + ex.getMessage());
}
}
public void desconecta(){
try {
conn.close();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null,"Erro ou achar a conexao " + ex.getMessage());
}
}
}