0
I have a question about how to generate the JDBC Java connection URL in the Netbeans IDE to connect to an online SQL Server database.
Below is my code, which did not generate a connection like the database:
package teste.br.com.DAO;
import java.sql.Connection;
import java.sql.DriverManager;
public class ConexaoSQLServer {
Connection con = null;
String driverDB = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String rota = "jdbc:sqlserver//sqlserver01.BASE_DADOS.com.br;databaseName=NOME;user=USER;"
+ "password=PASS;";
public boolean ConectarBD(){
try{
Class.forName(driverDB);
con = DriverManager.getConnection(rota);
return true;
}
catch(Exception ex){
ex.getMessage();
return false;
}
}
}
While debugging netbeans, I found that the problem is connecting to the online database.
Welcome Igor! Could you edit your question and add the error that is generated? Help the community have help! Thank you very much!
– Thiago Luiz Domacoski
Missing port, after host: sqlserver01.BASE_DADOS.com.br:1433
– Murillo Goulart
Take a look at the connectionstrings.with
– igventurelli
Actually no error occurred while running, even putting Try catch with the exceptions referring, only to debuggar I realize that my connection is null, I will check if the online database has some property that I did not specify in the url. Thank you so much for your help!
– Igor Bueno