• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

T4CConnection Datasource Jboss [RESOLVED]

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

I'm using a Datasource connection configured in xxx-ds.xml of Jboss Server.
and I'm using a methode who retrieves a Cursor from a stored procedure using CallableStatement
The problem is that I retrieve a proxy connection from the Datasource instead of T4CConnection !

Could any one help me pls !
thank you
[ May 06, 2007: Message edited by: BERDAI Adil ]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure you need the actual T4CConnection object? Cant you just work on the Connection interface returned through the datasource.getConnection() method? Is there something specific in the T4CConnection object that you want to use? If so, try the following:


 
BERDAI Adil
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply . I use a simple Connection in order to use CallabelStatement for stored procedure calls (retrieve Cursors). the type of the connection returned by datasource.getConnection() is a proxy and it makes a ClassCastException : Cannot cast $Proxy3 at line (**)

myCallableStatement = conn.prepareCall("begin GET_INDICATORS(?,?); end;", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

myCallableStatement.setInt(1, param);
myCallableStatement.registerOutParameter(2,oracle.jdbc.OracleTypes.CURSOR);
myCallableStatement.execute();
(**) rs = ((OracleCallableStatement)myCallableStatement).getCursor(2);

on the other hand, when I use a simple connection :
conn = DriverManager.getConnection(URL) it works fine ! and the connection returned by datasource.getConnection() is T4CConnection Type !
I'm constrained to use datasource provided in jboss descriptor :-(
any help ?
I thank you

Adil
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a bit confused. Can you post the code where you are doing this and also the exception stacktrace?
 
BERDAI Adil
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
at first, I retrieve the datasource and the connection using these two methods where ds is an attribut of my class DBManager : public DataSource ds = null;

this is the constructor used by getInstance method to have a singelton :

private DBManager() throws NamingException {
logger.debug("Begin DBManager()");
Context initContext = new InitialContext();
Object obj = initContext.lookup("MyDS");
logger.debug("objref class= " + obj.getClass());
logger.debug("objref class= " + obj.getClass().getClassLoader());
ds= (DataSource) obj;
logger.debug("End DBManager()");
}



public final Connection getConnection() throws SQLException {
logger.debug("Begin getConnection()");
Connection conn = null ;
if (ds != null) {
try {
conn = (Connection) ds.getConnection();
conn.setAutoCommit(false);
} catch (SQLException e) {
e.printStackTrace();
logger.error("Fail to create connecxion "+ e.getMessage());
}

} else {
logger.warn("Data Source is null");
}

logger.debug("End getConnection()");
return conn;
}



this is the myDS-ds.xml descriptor :
<?xml version="1.0" encoding="UTF-8"?>

<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->

<datasources>
<local-tx-datasource>
<jndi-name>MyDS</jndi-name>
<!-- Using global namespace. In this case, JNDI name of Oracle DS is OracleDS -->
<use-java-context>false</use-java-context>

<connection-url>jdbc racle:thin:@152.148.10.160:1521 rcl</connection-url>

<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>auto</user-name>
<password>auto</password>

<connection-property name="char.encoding">UTF-8</connection-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
</local-tx-datasource>

</datasources>



this is the trace :

[08/mars/2007 16:37:54:859] DEBUG: com.solutions.auto.persistence.connection.DBManager.getConnection : End getConnection()
java.lang.ClassCastException: $Proxy3
at com.solutions.auto.persistence.indicator.IndicatorDaoImpl.selectIndicators(IndicatorDaoImpl.java:81)
at com.solutions.auto.persistence.indicator.TestIndicatorDaoImpl.testSelectIndicators(TestIndicatorDaoImpl.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Thank you

Adil
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if this works:



Give it a try and let us know how it goes. I havent tried this before.
 
BERDAI Adil
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it always throws an exception of java.lang.ClassCastException: $Proxy3
at ligne :
org.jboss.resource.adapter.jdbc.WrappedCallableStatement wrappedCallableStatement = (WrappedCallableStatement) myCallableStatement;

I have inspected the value of myCallableStatement before throwing the exception and I have found that's a proxy =$Proxy3 (id=38) ! it contains a hClientContainer !


thank you
 
BERDAI Adil
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To clarify things, I'm trying to access to a datasource from a standalone client. I got an answer in this website :
http://wiki.jboss.org/wiki/Wiki.jsp?page=HowCanIAccessADataSourceFromAClient

Do you have any example to get connection by using EJBs ?

Thank you
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

To clarify things, I'm trying to access to a datasource from a standalone client



Not sure whether the issue you are seeing is because of that.

Do you have any example to get connection by using EJBs ?



If you are familiar with EJBs you might understand the code that has been provided in this similar thread.
[ March 08, 2007: Message edited by: Jaikiran Pai ]
 
BERDAI Adil
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much
The connection provided by datasource descriptor in jboss is incompatible with Cursor handling. If you use a simple request (with PreparedStatement or Statement), there is no difference. Meanwhile, if you handle or retrieve cursors from stored procedures, then this connection which is just a proxy is not really very compatible with ..you'd rather use EJB to provide a real Datasource
I think that EJBs will simplify things even if their deployement is a little bit complicated

Thank you
 
BERDAI Adil
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it ! It seems that the datasource provided by jboss in standalone mode (using JUnit for tests) is incompatible. It's also not recommanded by jboss..
That's what I did !
When I depoloyed my application on the server, the application worked well..
So, handling Cursor is compatible with this kind of Datasources except for standalone application
thank you

Adil
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic