Gentlemen,
I am trying to connect to a local MS SQLServer 2000 database with jTDS driver using the following mssql-ds.xml placed in /server/default/deploy:
<?xml version="1.0" encoding="UTF-8"?>
<!-- ==========================
==========
==========
==========
==========
=== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ==========================
==========
==========
==========
==========
=== -->
<!-- $Id: mssql-ds.xml 23720 2004-09-15 14:37:40Z loubyansky $ -->
<!-- ==========================
==========
==========
==========
==========
====-->
<!-- New ConnectionManager setup for Microsoft SQL Server 2000 driver -->
<!-- You may download the latest Microsoft JDBC driver from *Microsoft* -->
<!--
http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/MSDN-FILES/027/001/779/msdncompositedoc.xml&frame=true -->
<!-- ==========================
==========
==========
==========
==========
=== -->
<datasources>
<local-tx-datasource>
<jndi-name>AsistMedWebData
Source</jn
di-name>
<connection-url>jdbc:jtds:
sqlserver:
//localhos
t:1433/Asi
stmedDB;Se
lectMethod
=cursor;us
er=Propiet
ario;passw
ord=asistm
ed</connec
tion-url>
<driver-class>net.sourcefo
rge.jtds.j
dbcx.JtdsD
ataSource<
/driver-cl
ass>
<!--driver-class>net.sourc
eforge.jtd
s.jdbc.Dri
ver</drive
r-class-->
<user-name>Propietario</us
er-name>
<password>asistmed</passwo
rd>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>MS SQLSERVER2000</type-mappin
g>
</metadata>
</local-tx-datasource>
</datasources>
My jboss-web.xml file is placed in the root of the /classes directory:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN" "
http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/AsistMe
dWebDataSo
urce</res-
ref-name>
<jndi-name>java:/AsistMedW
ebDataSour
ce</jndi-n
ame>
</resource-ref>
</jboss-web>
And the corresponding entry in my web.xml file is:
<resource-ref>
<description>Definicion datasource BD AsistMed</description>
<res-ref-name>jdbc/AsistMe
dWebDataSo
urce</res-
ref-name>
<res-type>javax.sql.DataSo
urce</res-
type>
<res-auth>Container</res-a
uth>
</resource-ref>
I'm using this java code:
InitialContext initCtx = new InitialContext();
DataSource ds = (DataSource)initCtx.lookup
("java:com
p/env/jdbc
/AsistMedW
ebDataSour
ce");
logger.info("HistoriaClini
caDispatch
Action.obt
enerConecc
ion(): data source obtained!");
Connection conn = ds.getConnection();
I
UNFORTUNATELY, I'm getting this exception on the server.log file:
2007-06-26 12:24:23,125 INFO [com.asistmed.historiaclin
ica.action
.HistoriaC
linicaDisp
atchAction
] HistoriaClinicaDispatchAct
ion.obtene
rConeccion
(): data source obtained!
2007-06-26 12:24:23,140 DEBUG [org.jboss.resource.connec
tionmanage
r.IdleRemo
ver] internalRegisterPool: registering pool with interval 900000 old interval: 9223372036854775807
2007-06-26 12:24:23,140 DEBUG [org.jboss.resource.connec
tionmanage
r.IdleRemo
ver] internalRegisterPool: about to notify thread: old next: 1182879113140, new next: 1182879113140
2007-06-26 12:24:24,281 DEBUG [org.jboss.util.NestedThro
wable] org.jboss.util.NestedThrow
able.paren
tTraceEnab
led=true
2007-06-26 12:24:24,281 DEBUG [org.jboss.util.NestedThro
wable] org.jboss.util.NestedThrow
able.neste
dTraceEnab
led=false
2007-06-26 12:24:24,281 DEBUG [org.jboss.util.NestedThro
wable] org.jboss.util.NestedThrow
able.detec
tDuplicate
Nesting=tr
ue
2007-06-26 12:24:24,281 WARN [org.jboss.resource.connec
tionmanage
r.JBossMan
agedConnec
tionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossRe
sourceExce
ption: Could not create connection; - nested throwable: (java.sql.SQLException: Network error IOException: Connection refused: connect)
at org.jboss.resource.adapter
.jdbc.loca
l.LocalMan
agedConnec
tionFactor
y.createMa
nagedConne
ction(Loca
lManagedCo
nnectionFa
ctory.java
:179)
...
...
Caused by: java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.
Connection
JDBC2.<ini
t>(Connect
ionJDBC2.j
ava:372)
at net.sourceforge.jtds.jdbc.
Connection
JDBC3.<ini
t>(Connect
ionJDBC3.j
ava:50)
at net.sourceforge.jtds.jdbc.
Driver.con
nect(Drive
r.java:178
)
at org.jboss.resource.adapter
.jdbc.loca
l.LocalMan
agedConnec
tionFactor
y.createMa
nagedConne
ction(Loca
lManagedCo
nnectionFa
ctory.java
:171)
... 46 more
Caused by: java.net.ConnectException:
Connection refused: connect
at java.net.PlainSocketImpl.s
ocketConne
ct(Native Method)
at java.net.PlainSocketImpl.d
oConnect(P
lainSocket
Impl.java:
305)
at java.net.PlainSocketImpl.c
onnectToAd
dress(Plai
nSocketImp
l.java:171
)
at java.net.PlainSocketImpl.c
onnect(Pla
inSocketIm
pl.java:15
8)
at java.net.Socket.connect(So
cket.java:
464)
at sun.reflect.NativeMethodAc
cessorImpl
.invoke0(N
ative Method)
at sun.reflect.NativeMethodAc
cessorImpl
.invoke(Na
tiveMethod
AccessorIm
pl.java:39
)
at sun.reflect.DelegatingMeth
odAccessor
Impl.invok
e(Delegati
ngMethodAc
cessorImpl
.java:25)
at java.lang.reflect.Method.i
nvoke(Meth
od.java:32
4)
at net.sourceforge.jtds.jdbc.
SharedSock
et.createS
ocketForJD
BC3(Shared
Socket.jav
a:289)
at net.sourceforge.jtds.jdbc.
SharedSock
et.<init>(
SharedSock
et.java:25
0)
at net.sourceforge.jtds.jdbc.
Connection
JDBC2.<ini
t>(Connect
ionJDBC2.j
ava:297)
... 49 more
I guess I'm CLOSE TO SOLVING IT, but I'm just missing something..WHAT IS STRANGE is the fact that it's a localhost connection but I'm getting a connection refused error. Obviously, I checked the MS SqlServer service is running on my PC.
Thanks for your help
Start Free Trial