Witam, probuje sie polaczyc z MSSQL mniej wiecej tak:
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
//con = DriverManager.getConnection("jdbc:sqlserver://localhost:5530/NB", "sa", "12345");
con = DriverManager.getConnection("jdbc:sqlserver://localhost;user=sa;password=12345;databaseName=NB");
if(!con.isClosed());
} catch(Exception e1) {
System.err.println("Exception: " + e1.getMessage());
} finally {
try {
statement = con.prepareStatement("SELECT surname FROM tab1 order by name asc");
rs = statement.executeQuery();
while(rs.next()) rowcount++;
for(int i=1; i<=rowcount; i++)
{
if (rs.absolute(i))
zmienna = rs.getString("surname").trim();
tekst.setText(zmienna);
//ListaGlowna.add(zmienna);
}
if(con != null)
con.close();
} catch(Exception e1) {}
}
Program sie kompiluje ale jak chce polaczyc sie z baza krzyczy:
Exception: The TCP/IP connection to the host localhost/DCPC2011/DBPC, port 1433 has failed. Error: "null. 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.".
Wchodzilem juz w SQL Server Configuration Manager -> TCP/IP -> IP Adress ustawilem All IP dla TCP IP PORT 1433 i nic wciaz ten sam blad ... zetknal sie ktos z podobnym problemem ? jak go obejsc by polaczyc sie z baza ?