Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

The TCP/IP connection to the host localhost, port 1433 has failed.

derokDec 8 2010 — edited Dec 13 2010
Hi, im using sql server 2000,
i have declared this in my program:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1433;databaseName=Factura";
Connection conn = DriverManager.getConnection(url,"sa","");
and is giving me this exception:
run:
Got an exception! 
The TCP/IP connection to the host localhost, port 1433 has failed. 
Error: "connect timed out. 
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.".
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. 
Error: "connect timed out. 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.".
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1033)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:817)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:700)
        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:842)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at factura.FacturaView.conexion(FacturaView.java:317)
        at factura.FacturaView.jTextField1KeyPressed(FacturaView.java:268)
        at factura.FacturaView.access$900(FacturaView.java:41)
        at factura.FacturaView$5.keyPressed(FacturaView.java:150)
        at java.awt.Component.processKeyEvent(Component.java:6225)
        at javax.swing.JComponent.processKeyEvent(JComponent.java:2801)
        at java.awt.Component.processEvent(Component.java:6044)
        at java.awt.Container.processEvent(Container.java:2041)
        at java.awt.Component.dispatchEventImpl(Component.java:4630)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1850)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:712)
        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:990)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:855)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:676)
        at java.awt.Component.dispatchEventImpl(Component.java:4502)
        at java.awt.Container.dispatchEventImpl(Container.java:2099)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4460)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 34 seconds)
how can i solve this?

thanks..

Edited by: derok on Dec 8, 2010 1:31 PM

Edited by: derok on Dec 8, 2010 9:14 PM

Edited by: derok on Dec 11, 2010 1:51 PM

Edited by: derok on Dec 11, 2010 1:52 PM
This post has been answered by EJP on Dec 12 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2011
Added on Dec 8 2010
23 comments
14,551 views