Damon4hire Posted November 26, 2009 at 04:50 PM Report Share #297637 Posted November 26, 2009 at 04:50 PM boas pessoal mais uma vez lol. Comecei agora as ligações a bd's, e estou a fazer alguma coisa mal na conecção. Até agora tenho isto: protected static Connection connect; static { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); } catch(ClassNotFoundException ex) { ex.printStackTrace(); System.exit(1); } } protected LinksBD() throws SQLException { initConnection(); } protected static void initConnection() throws SQLException { connect = DriverManager.getConnection("jdbc:microsoft.sqlserver://localhost; DatabaseName = Loja; integratedSecurity = true"); } Mas o mais estranho não é ele não ligar, ele nem sequer dá erros ou excepções, apenas faz o build successful, quando o tento correr. Agradeço a ajuda. Link to comment Share on other sites More sharing options...
Baderous Posted November 26, 2009 at 05:04 PM Report Share #297639 Posted November 26, 2009 at 05:04 PM Se estás a usar a versão 6 do Java, já não precisas do Class.forName(...). Link to comment Share on other sites More sharing options...
Damon4hire Posted November 26, 2009 at 05:20 PM Author Report Share #297642 Posted November 26, 2009 at 05:20 PM lol ok ja m deu outra coisa. Uma excepção: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.". java.lang.NullPointerException Nao tenho firewall activa de momento, incluindo a do windows. De resto nao sei mexer. Link to comment Share on other sites More sharing options...
KiNgPiTo Posted November 26, 2009 at 05:39 PM Report Share #297645 Posted November 26, 2009 at 05:39 PM mas devo apagar so o ClassForName, o bloco static inteiro, ...? N percebi 🙂 Isto podes limpar... try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); } catch(ClassNotFoundException ex) { ex.printStackTrace(); System.exit(1); } Quanto ao "acontecer alguma coisa"... O que estás a espera que aconteça? Apenas estás a criar a criar uma connection, não estás a fazer nada com ela Link to comment Share on other sites More sharing options...
Damon4hire Posted November 26, 2009 at 05:41 PM Author Report Share #297646 Posted November 26, 2009 at 05:41 PM n mostrei mas depois estou a querer que faca print de alguma informacao da bd, para ver se a connection funciona. O importante e a connection que n consigo estabelecer update: ja ca está tks anyway ppl Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now