Advertisement

06.26.2007 at 10:41AM PDT, ID: 22659095
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

JBOSS jdbc connection to MS SQLServer 2000 using jTDS driver:

Asked by eduardotorres17 in Jboss Application Server, MS SQL Server, J2EE

Tags: , ,

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>AsistMedWebDataSource</jndi-name>
        <connection-url>jdbc:jtds:sqlserver://localhost:1433/AsistmedDB;SelectMethod=cursor;user=Propietario;password=asistmed</connection-url>
    <driver-class>net.sourceforge.jtds.jdbcx.JtdsDataSource</driver-class>
    <!--driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class-->
    <user-name>Propietario</user-name>
    <password>asistmed</password>
       
       
      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
      <metadata>
         <type-mapping>MS SQLSERVER2000</type-mapping>
      </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/AsistMedWebDataSource</res-ref-name>
      <jndi-name>java:/AsistMedWebDataSource</jndi-name>
   </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/AsistMedWebDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>

I'm using this java code:

InitialContext initCtx = new InitialContext();
                  DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/AsistMedWebDataSource");
                  logger.info("HistoriaClinicaDispatchAction.obtenerConeccion(): 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.historiaclinica.action.HistoriaClinicaDispatchAction] HistoriaClinicaDispatchAction.obtenerConeccion(): data source obtained!
2007-06-26 12:24:23,140 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] internalRegisterPool: registering pool with interval 900000 old interval: 9223372036854775807
2007-06-26 12:24:23,140 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] internalRegisterPool: about to notify thread: old next: 1182879113140, new next: 1182879113140
2007-06-26 12:24:24,281 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.parentTraceEnabled=true
2007-06-26 12:24:24,281 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.nestedTraceEnabled=false
2007-06-26 12:24:24,281 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.detectDuplicateNesting=true
2007-06-26 12:24:24,281 WARN  [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Network error IOException: Connection refused: connect)
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:179)
...
...
Caused by: java.sql.SQLException: Network error IOException: Connection refused: connect
      at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:372)
      at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
      at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:178)
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:171)
      ... 46 more
Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
      at java.net.Socket.connect(Socket.java:464)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:289)
      at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:250)
      at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java: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
[+][-]06.26.2007 at 10:54AM PDT, ID: 19366152

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Jboss Application Server, MS SQL Server, J2EE
Tags: jboss, connection, jtds
Sign Up Now!
Solution Provided By: twoboats
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.19.2008 at 04:56AM PDT, ID: 21160482

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.03.2008 at 03:54AM PDT, ID: 22375806

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09.08.2008 at 05:17PM PDT, ID: 22423024

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32