persistence@glassfish.java.net

RE: connection DB error

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Wed, 31 Oct 2007 16:52:34 +0000

Hello Jaqadish, everyone,

This is probably a little mistake I am making because I have done before and had managed to
resolve some issued in the past. I am not getting the following error:

'Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: Connection could not be allocated because: The TCP/IP connection to the host has failed. java.net.UnknownHostException:'


So it seems the error message:

'The connection to the named instance has failed'

was due to the mistake in the database server name. So I made some corrections and now get the above error.
I am also using the following client to test it apart from the admin console:


import java.sql.*;public class clientFailover{ public static void main(String[] args) { // Create a variable for the connection string. String connectionUrl = "jdbc:sqlserver://SQLEXPRESS:1433;" + "databaseName=TESTING1;integratedSecurity=false;" + "failoverPartner=serverB"; // Declare the JDBC objects. Connection con = null; Statement stmt = null; try { // Establish the connection to the principal server. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con = DriverManager.getConnection(connectionUrl); System.out.println("Connected to the principal server."); // Note that if a failover of serverA occurs here, then an // exception will be thrown and the failover partner will // be used in the first catch block below. // Create and execute an SQL statement that inserts some data. stmt = con.createStatement(); // Note that the following statement assumes that the // TestTable table has been created in the AdventureWorks // sample database. stmt.executeUpdate("INSERT INTO TestTable (Col2, Col3) VALUES ('a', 10)"); } // Handle any errors that may have occurred. catch (SQLException se) { try { // The connection to the principal server failed, // try the mirror server which may now be the new // principal server. System.out.println("Connection to principal server failed, " + "trying the mirror server."); con = DriverManager.getConnection(connectionUrl); System.out.println("Connected to the new principal server."); stmt = con.createStatement(); stmt.executeUpdate("INSERT INTO TestTING1 (Col2, Col3) VALUES ('a', 10)"); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } // Close the JDBC objects. finally { if (stmt != null) try { stmt.close(); } catch(Exception e) {} if (con != null) try { con.close(); } catch(Exception e) {} } }}
I copied it off the JDBC connection tutorial
Anymore idea? The database server service is running and TCP is enabled.

eve


From: gorgeous65_at_msn.com
To: persistence_at_glassfish.dev.java.net
CC: ejb_at_glassfish.dev.java.net
Date: Wed, 31 Oct 2007 14:22:24 +0000
Subject: RE: connection DB error








Hello, Jaqadish,

Thanks for your reply.

I have following the procedure of connecting to the database:

Data Sources

The JDBC driver provides support for J2EE / JDBC 3.0 data sources. The JDBC driver SQLServerXADataSource class is implemented by com.microsoft.sqlserver.jdbc.SQLServerXADataSource.
Datasource Names

You can make database connections by using data sources. The data sources available with JDBC driver are described in the following table:
DataSource Type Class Name Description

DataSource
    

com.microsoft.sqlserver.jdbc.SQLServerDataSource
    

The non pooling data source.

ConnectionPoolDataSource
    

com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource
    

The data source to configure J2EE application server connection pools. Typically used when the application runs within a J2EE application server.

XADataSource
    

com.microsoft.sqlserver.jdbc.SQLServerXADataSource
    

The data source to configure J2EE XA data sources. Typically used when the application runs within a J2EE application server and an XA transaction manager.
Data Source Propertiesf


That is the help menu which comes with the JDBC driver. I have done this before but it just that the error messages are always different. Sometimes it referees to the datasource or class name if it's wrong.

In this case, I am not sure about the name instance error message:

'The connection to the named instance has failed'

I will trying connecting to the database without going through the application server. I am able to go connect to the DB through the SQL server management studio express.

Anymore suggestions.

Thanks

eve


> Date: Wed, 31 Oct 2007 19:30:43 +0530
> From: Jagadish.Ramu_at_Sun.COM
> To: persistence_at_glassfish.dev.java.net
> CC: ejb_at_glassfish.dev.java.net
> Subject: Re: connection DB error
>
> 1) Are you able to connect to the microsoft sql server using a
> standalone jdbc program ?
>
> 2) you can set your pool config. according to
> "microsoft_sqlserver2005_datasource.xml" available in
> 91_AS_INSTALL_ROOT/lib/install/templates/resources/jdbc
>
> Thanks,
> -Jagadish
>
> On Wed, 2007-10-31 at 12:26 +0000, Eve Pokua wrote:
> > Hello everyone,
> >
> > I uninstalled my SQL server 2005 express and reinstalled an updated
> > version. I get the following while trying to connect to the DB from
> > the application server SUN 9:
> >
> > "Operation 'pingConnectionPool'
> > failed in 'resources' Config
> > Mbean. Target exception message:
> > Connection could not be allocated
> > because: The connection to the
> > named instance has failed. Error:
> > java.net.SocketTimeoutException:
> > Receive timed out."
> >
> > After spending a couple days researching and trying to resolve the
> > issue, I got fedup and uninstalled the SQL server 2005 express updated
> > version. I also made sure the Old profile was deleted from my
> > 'program files' so i didn't have to encounter the same issue after.
> > However, I am still having the same error after installing the old SQL
> > server express 2005. What I'm I doing wrong? I am sure the property
> > settings are correct too. I've had this kind of error whilst trying
> > to connect to the DB from the application server before, but may be
> > not the same type of error. I have always managed to resolve the
> > issue but this time I'm running out of ideas. Though, there are a
> > lot of post on the internet, the error message is not always the
> > same.
> >
> > I think, it has something about me uninstalling the Old SQL server
> > 2005 express and installing a new one and so forth. Maybe the
> > application server keeps data of some kind of the DB. Pls help. I am
> > running out of ideas.
> >
> > thanks
> >
> > eve
> >
> >
> > ______________________________________________________________________
> > Do you know a place like the back of your hand? Share local knowledge
> > with BackOfMyHand.com

Play Movie Mash-up and win BIG prizes!

_________________________________________________________________
Get free emoticon packs and customisation from Windows Live.
http://www.pimpmylive.co.uk