I am using WSAD 5.1.1 and Build in Websphere 5.1: Test Environment
Server.
I set up data source using different JDBC drivers for SQL 2000 and use
simple java class to test Data Source Setup.
Any of them does not work to create ConnectionPoolDataSource,
even though they work fine to create regular DataSource.
Of Course I use different implementation class to create DataSource
and ConnectionPoolDataSource.
The error is:
java.lang.ClassCastException:
com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource that refers to the next
line in code:
ds = (javax.sql.ConnectionPoolDataSource)ctx.lookup("jdbc/optads");
Thank you in advance,
Adnrew
WSCL0035I: Initialization of the J2EE Application Client Environment
has completed.
WSCL0014I: Invoking the Application Client class
billing.ejb.clients.DSTest
java.lang.ClassCastException:
com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource
at billing.ejb.clients.DSTest.main(DSTest.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.websphere.client.applicationclient.launchClient.createContainerAndLaunchApp(launchClient.java:627)
at com.ibm.websphere.client.applicationclient.launchClient.main(launchClient.java:422)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
public class DSTest
{
public static void main(String[] args)
{
InitialContext ctx = null;
Hashtable parms = new Hashtable();
parms.put(
Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
//parms.put(Context.PROVIDER_URL, "iiop:///");
//javax.sql.DataSource ds = null;
ConnectionPoolDataSource ds = null;
try
{
ctx = new InitialContext(parms);
ds = (javax.sql.ConnectionPoolDataSource)ctx.lookup("jdbc/optads");
PooledConnection connP = ds.getPooledConnection("sa","sql");
Connection conn=connP.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select NumRows=count(*) from
products");
System.out.println("******************************");
while (rs.next())
{
String col1 = rs.getString(1);
System.out.println("The result is: " + col1);
}
System.out.println("******************************");
stmt.close();
conn.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
net__...@hotmail.com (Andy) wrote in message news:<edb90340.04012...@posting.google.com>...
To look up a DataSource you have to add it as a resource to the bean
calling it. This is done in ejb-jar.xml file, under the Reference tab.
The only problem is that it does not allow you to add a resource for a
ConnectionPoolDataSource since that is handled by the server.
Hope this helps,
Natalie
davesus...@hotmail.com (Dave) wrote in message news:<1cf6cbc4.04012...@posting.google.com>...