Bom estou tendo um erro chato q na verdade nunca consegui resolver, antigamente quando dava isso eu mudava de banco, mas agora a empresa usa Sql server e não tem Escapatória.
Quando eu tento me conectar.
public class ConnectionFactory {
public static Connection getConnection() throws SQLException {
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
return DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/Ceps","sa","");
} catch (ClassNotFoundException e) {
throw new SQLException(e.getMessage());
}
}
public static void main(String[] args) throws SQLException {
Connection c = ConnectionFactory.getConnection();
}
}
// E da Esse Erro:
Exception in thread "main" java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:395)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
N tem Jeito ja li o google inteiro, ja fiz d tudo e n consigo arrumar…
eu mudei uma linha e colokei um instance junto ao banco tipo…
return DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/Ceps;instance=Jefferson","sa","");
Mas da um outro erro :?
Exception in thread "main" java.sql.SQLException: Unable to get information from SQL Server: localhost.
at net.sourceforge.jtds.jdbc.MSSqlServerInfo.<init>(MSSqlServerInfo.java:97)
Será que alguem pode me orientar pq eu n sei mais oq fazer…
Muito Obrigado