Link to home
Start Free TrialLog in
Avatar of jazzIIIlove
jazzIIIloveFlag for Sweden

asked on

default instance vs. named instance in MSSQL 2008 "EXPRESS"

Hi;

I needed to install the EXPRESS version of MSSQL 2008 and this version dictates to get installed with a named instance, but i need to have it as default instance. (and I couldn't)

Now the root of the case is that I have  the following ROOT.xml of Catalina tomcat and I couldn't set it up to run the named instance db.

<?xml version='1.0' encoding='utf-8'?>
<Context useNaming="true">
    <!--
    Replace the username, password and url parameters.
    In the URL the name after the last slash is the database name.
    The database must have been created, but be otherwise empty.
    -->
    <Resource name="jdbc/Test" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://localhost:1433/JAZZ" maxActive="8" maxIdle="4" />

    <!-- This is needed to use SQLServer -->
    <Environment name="hibernateDialect" value="org.hibernate.dialect.SQLServerDialect" type="java.lang.String" override="false" />
</Context>

Open in new window


Essentially when i changed the localhost to my named instance, it's not working. It is working as above but I need to have it working with SQLEXPRESS.

Any help?

Regards.
Avatar of Nakul Vachhrajani
Nakul Vachhrajani
Flag of India image

The following immediately comes to mind:
1. Create an alias in the SQL Server Configuration Manager so that clients can use the alias name when connecting to your named instance
2. Connect using an IP address and port (Reference post here)
By the connection string it's trying to connect to port 1433. Verify using SQL Server Configuration Manager if TCP/IP is enabled and which port is configured for the SQL Server instance.

 <Resource name="jdbc/Test" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://localhost:1433/JAZZ" maxActive="8" maxIdle="4" />
Alternative is to use the InstanceName property:

 <Resource name="jdbc/Test" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://localhost;instanceName=SQLEXPRESS" maxActive="8" maxIdle="4" />

By the way, what's JAZZ? Was in the connection string after the port number.
Avatar of jazzIIIlove

ASKER

JAZZ is the database name.
Then you should add the correct parameter:
<Resource name="jdbc/Test" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://localhost:1433;databaseName=JAZZ" maxActive="8" maxIdle="4" />

Or with instance name:
<Resource name="jdbc/Test" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://localhost;instanceName=SQLEXPRESS;databaseName=JAZZ" maxActive="8" maxIdle="4" />
with instance name:
<Resource name="jdbc/Test" auth="Container" type="javax.sql.DataSource" username="test" password="test" driverClassName="net.sourceforge.jtds.jdbc.Driver" url="jdbc:jtds:sqlserver://localhost;instanceName=SQLEXPRESS;databaseName=JAZZ" maxActive="8" maxIdle="4" />

I had the following exception:

2015-01-21 16:25:38,246 ERROR - Cannot create PoolableConnectionFactory (Network error IOException: Connection refused: connect)
2015-01-21 16:25:38,248 WARN  - Could not obtain connection metadata
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Network error IOException: Connection refused: connect)
 at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
 at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
 at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
 at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
 at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
 at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
 at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
 at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)

Open in new window

You are running it from the same machine where is SQL Server or it's from a remote server?
ASKER CERTIFIED SOLUTION
Avatar of jazzIIIlove
jazzIIIlove
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it is a niche question and my solution works fine.