-
1. Re: NewConnection SQL execution
kalyan120 Jan 10, 2005 11:38 PM (in response to kalyan120)We are using JBoss application server in our application as a middle-tier. We are using JBoss JCA to create connection pools to the required databases. In order to do this, we are generating a sybase-ds.xml file at the server startup and then JBoss loads this service and creates the specified connection pools. We require some temporary tables to be created for every connection that's created in the connection pool. So, in the sybase-ds.xml file, we are specifying the <new-connection-sql> element to contain the required SQL. We have quite a big SQL in some cases, that needs to be executed once the connection is created and is returned to the user for further use (It's as big as 1200 lines of SQL code).
In instances where the SQL is small, the connection returned is initialized with the temp tables and everything works fine. But in situations where the SQL is big, only part of the SQL is getting executed. Only some temp tables were getting created and some of them were not getting created. Hence, we are facing problems when we run queries on these connections.
I have looked at the code of JBoss to figure out how this <new-connection-sql> is getting used. The sybase-ds.xml file is transformed into an XML form of Mbean before JBoss tries to create the connection pools.
This particular variable is present in org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory class. This class has accessor methods for this attribute. But, when I tried to do a search on the references to this variable, or any of these accessor methods, I wasn't able to find any. I want to output the SQL string that's being used to execute once the connection is created.
Is there any way in which I can get to print this SQL string? Also, is anybody aware of any limits on the new-connection-sql property (it's a String object, so I don't think there would be any limit)? -
2. Re: NewConnection SQL execution
starksm64 Jan 11, 2005 8:41 AM (in response to kalyan120)org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection uses it:
/** * Checks whether a connection is valid */ SQLException isValidConnection(Connection c) { // Already got a checker if (connectionChecker != null) return connectionChecker.isValidConnection(c); // Class specified if (validConnectionCheckerClassName != null) { try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class clazz = cl.loadClass(validConnectionCheckerClassName); connectionChecker = (ValidConnectionChecker) clazz.newInstance(); return connectionChecker.isValidConnection(c); } catch (Exception e) { log.warn("Exception trying to create connection checker (disabling):", e); connectionChecker = new NullValidConnectionChecker(); } } // SQL statement specified if (checkValidConnectionSQL != null) { connectionChecker = new CheckValidConnectionSQL(checkValidConnectionSQL); return connectionChecker.isValidConnection(c); } // No Check return null; }