Foros del Web » Programación para mayores de 30 ;) » Java »

Ayuda con conexion de SQL SERVER 2000

Estas en el tema de Ayuda con conexion de SQL SERVER 2000 en el foro de Java en Foros del Web. Hola a todos, Estoy programando en java y como me conecto es de la siguiente forma: Properties p = new Properties(); p.put("user", "sa"); p.put("password","123"); p.put("selectMethod", ...
  #1 (permalink)  
Antiguo 03/07/2007, 01:09
 
Fecha de Ingreso: julio-2007
Mensajes: 1
Antigüedad: 16 años, 10 meses
Puntos: 0
Pregunta Ayuda con conexion de SQL SERVER 2000

Hola a todos,
Estoy programando en java y como me conecto es de la siguiente forma:

Properties p = new Properties();
p.put("user", "sa");
p.put("password","123");
p.put("selectMethod", "direct");
p.put("DatabaseName", "pubs");

conn = java.sql.DriverManager.getConnection("jdbc:jtds:sq lserver://HOME:1433/pubs", p);

y me da el siguiente error:

java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(C onnectionJDBC2.java:372)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(C onnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.ja va:178)
at java.sql.DriverManager.getConnection(DriverManager .java:525)
at java.sql.DriverManager.getConnection(DriverManager .java:140)
at Conectarse.<init>(Conectarse.java:69)
at Escolare.Cargar(Escolare.java:318)
at Escolare.btnAceptarActionPerformed(Escolare.java:1 97)
at Escolare.access$1600(Escolare.java:13)
at Escolare$17.actionPerformed(Escolare.java:157)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener$Actions .actionPerformed(BasicButtonListener.java:287)
at javax.swing.SwingUtilities.notifyAction(SwingUtili ties.java:1571)
at javax.swing.JComponent.processKeyBinding(JComponen t.java:2763)
at javax.swing.JComponent.processKeyBindings(JCompone nt.java:2798)
at javax.swing.JComponent.processKeyEvent(JComponent. java:2726)
at java.awt.Component.processEvent(Component.java:526 5)
at java.awt.Container.processEvent(Container.java:196 6)
at java.awt.Component.dispatchEventImpl(Component.jav a:3955)
at java.awt.Container.dispatchEventImpl(Container.jav a:2024)
at java.awt.Component.dispatchEvent(Component.java:38 03)
at java.awt.KeyboardFocusManager.redispatchEvent(Keyb oardFocusManager.java:1810)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEv ent(DefaultKeyboardFocusManager.java:672)
at java.awt.DefaultKeyboardFocusManager.preDispatchKe yEvent(DefaultKeyboardFocusManager.java:920)
at java.awt.DefaultKeyboardFocusManager.typeAheadAsse rtions(DefaultKeyboardFocusManager.java:798)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent (DefaultKeyboardFocusManager.java:636)
at java.awt.Component.dispatchEventImpl(Component.jav a:3841)
at java.awt.Container.dispatchEventImpl(Container.jav a:2024)
at java.awt.Window.dispatchEventImpl(Window.java:1778 )
at java.awt.Component.dispatchEvent(Component.java:38 03)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 463)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:110)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl .java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSoc ketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:366)
at java.net.Socket.connect(Socket.java:516)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocke tForJDBC3(SharedSocket.java:289)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(Shar edSocket.java:250)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(C onnectionJDBC2.java:297)
... 38 more



Como pueda hacer para conectarme?, se los agradeceria mucho
mi correo es [email protected]
  #2 (permalink)  
Antiguo 03/07/2007, 12:58
Avatar de La__X  
Fecha de Ingreso: junio-2005
Mensajes: 21
Antigüedad: 18 años, 10 meses
Puntos: 0
Re: Ayuda con conexion de SQL SERVER 2000

Pues te falta indicarle el driver. Que driver estas empleando?
yo utilizo el jtds y hago lo sgte:

el properties debe tener lo siguiente:

url=jdbc:jtds:sqlserver://localhost:1433/db_Prueba
driver=net.sourceforge.jtds.jdbc.Driver
user=sa
password=sa

y al conectarse
Connection con = getConnection(
j.getDriver(), j.getUrl(), j.getUser(), j.getPassword()
);
siendo j, tu variable tipo properties
Yo utilizo un archivo tipo properties para que me sirvar para todas mis conexiones.
Ojala te sirva y lo adecues a lo que debes hacer

Última edición por La__X; 03/07/2007 a las 13:28
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:10.