[jboss-user] [JCA/JBoss] - DataSource.getConnection problem

realvalkyrie do-not-reply at jboss.com
Mon Apr 7 03:43:34 EDT 2008

Thank U 4 all from beginning !!!!!!!
my code is below:

private InitialContext 	initial = null; 
private DataSource 	dataSource = null;

public synchronized Connection getConnection(String name) {
		try { 
			if(name==null) name = "";
			initial    =  new InitialContext(); 
			dataSource = (DataSource) initial.lookup("java:/jdbc/"+name);
			Connection con = dataSource.getConnection(); 
			return con;
		} catch (SQLException e) { 
			System.out.print("can not get connection ...java:/jdbc/"+name);
			System.out.println("SQLException  cause ~~~"+e.getMessage());
			return null;
		} catch (NamingException e1) {
			System.out.println("NamingException  cause ~~~"+e1.getMessage());
			return null;
		} finally{
			try {
				if(initial!=null)	initial.close();
			} catch (NamingException e) {
				System.out.println("Error Closing InitialContext cause---->"+e.getMessage());

it always work perfect ,but  sometimes the system will throw the follow Exception , this is the details:

INFO    [STDOUT] can not get connection...java:/jdbc/et
ERROR [STDERR] java.sql.SQLException: JZ006: capture io exception :com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0: the connection has already been closed .

here is my -ds.xml configuration 

    < p a s s w o r d>**</ p a s s w o r d >
    <blocking - timeout - millis>10000</blocking - timeout -  millis>

help me   please  
thank u everyone !!!!!!!!!!!!
      shoud i  add this issue in the xml files to avoid that exception ?
<check-valid-connection-sql>some check sql</check-valid-connection-sql>

and make the initialcontext , datasource to static ?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4141970#4141970

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4141970

More information about the jboss-user mailing list