5 Replies Latest reply on Oct 30, 2008 1:06 PM by vitechinc2008

    MS SQL datasource error

    vitechinc2008

      Hi.

      I am new add JBOSS, got Oracle datasource to work, Now I need to connect to SQL 2005 but I am getting the following error:
      Datasource config


      <local-tx-datasource>
      <jndi-name>basic_ds</jndi-name>
      <use-java-context>false</use-java-context>
      <connection-url>jdbc:microsoft:sqlserver://172.24.42.102:1433;DatabaseName=V3Test</connection-url>
      <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
      <user-name>password</user-name>
      password


      <type-mapping>MS SQLSERVER2000</type-mapping>

      </local-tx-datasource>



      Error

      15:30:21,455 INFO [[/EQUITRAK]] Initializing Spring root WebApplicationContext
      15:31:16,754 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Apparently wrong driver class specified for URL: class: com.microsoft.sqlserver.jdbc.SQLServerDriver, url: jdbc:microsoft:sqlserver://172.24.42.102:1433;DatabaseName=V3Test)
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:190)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:619)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:264)
      at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:575)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:347)
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:330)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:402)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
      at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:77)
      at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:73)
      at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1156)
      at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:790)
      at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:540)
      at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:474)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:365)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$ConstructorResolverAdapter.findAutowireCandidates(AbstractAutowireCapableBeanFactory.java:1318)

        • 1. Re: MS SQL datasource error
          vitechinc2008

          update datasource configuration


          <local-tx-datasource>
          <jndi-name>basic_ds</jndi-name>
          <use-java-context>false</use-java-context>
          <connection-url>jdbc:microsoft:sqlserver://172.24.42.102:1433;DatabaseName=V3Test</connection-url>
          <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
          <user-name>password</user-name>
          password


          <type-mapping>MS SQLSERVER2000</type-mapping>

          </local-tx-datasource>

          • 2. Re: MS SQL datasource error
            peterj

            Did you place the SQL Server JBDC driver JAR file into the server/xxx/lib directory?

            Also, use the 'code' tag when posting XML text (select the text, click the Code button). Click the Preview button and check the formatting before submitting your post.

            • 3. Re: MS SQL datasource error
              vitechinc2008

              Thanks for advice...I will remember it next time:

              Now that i have copy the jar file to lib directory. I am getting the following error:

              Does it mean I have the wrong driver:


              -----Error----
              2008-10-30 11:23:41,012 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.parentTraceEnabled=true
              2008-10-30 11:23:41,012 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.nestedTraceEnabled=false
              2008-10-30 11:23:41,012 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.detectDuplicateNesting=true
              2008-10-30 11:23:41,012 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: (com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect)
              at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:190)
              at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:619)
              at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:264)
              at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:575)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:347)
              at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:330)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:402)
              at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849)
              at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
              at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:77)
              at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:73)
              at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1156)
              at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:790)
              at org.springframework.orm.hibernate.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:540)
              at org.springframework.orm.hibernate.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:474)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
              at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:365)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$ConstructorResolverAdapter.findAutowireCandidates(AbstractAutowireCapableBeanFactory.java:1318)
              at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:472)
              at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:153)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:800)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:720)
              at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:387)
              at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
              at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
              at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
              at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:247)
              at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:796)
              at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:592)
              at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
              at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)

              • 4. Re: MS SQL datasource error
                peterj

                The "connection refused" message means that the app server could not establish a connection to the host running the data using the port specified (that is, there is nothing using that port). This usually means that either the database is not running, or it has opened a different port. Firewall issues can also cause this problem.

                Your first step would be to go to 172.24.42.102, make sure SQL Server is running, and then verify that SQL Server has port 1433 open. Once you have verified that, you should use a SQL Server utility to attempt to access the database. (It's been a long time since I used SQL Server and I cannot recall if they have a command line utility that you can use to query the database.) Once that is working, try with jbossas again.

                • 5. Re: MS SQL datasource error
                  vitechinc2008

                  Thank you for your help.

                  I am new with SQL 2005...I had to specific the instance name and that was causing the problem.


                  Thanks
                  Sayef