File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes datamining jndi connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "datamining jndi connection" Watch "datamining jndi connection" New topic
Author

datamining jndi connection

vasanthi naveen
Greenhorn

Joined: Oct 31, 2008
Posts: 10
iam getting the following error while connecting mysql with java for datamining.

java.lang.ClassCastException: org.apache.commons.dbcp.BasicDataSource

my code is:

test.jsp

html
head
title DB Test title
head
body

<%<br /> foo.MarketBasket tst = new foo.MarketBasket();<br /> tst.init();<br /> %>
</body>
</html>

MarketBasket.java

public void init()throws JDMException,NamingException, SQLException
{
Context ctx = new InitialContext();
System.out.println("after initial context");
javax.datamining.resource.ConnectionFactory jdmCFactory =
(ConnectionFactory) ctx.lookup("java:comp/env/jdbc/TestDB");
ConnectionSpec svrConnSpec = (javax.datamining.resource.ConnectionSpec)
jdmCFactory.getConnectionSpec();
System.out.println("got connection1");
svrConnSpec.setName( "username" );
svrConnSpec.setPassword( "password" );
svrConnSpec.setURI( "url" );
m_dmeConn = jdmCFactory.getConnection( svrConnSpec );
System.out.println("connection got");
}

server.xml

<Context path="/Databasemining" reloadable="true" docBase="D:\vasanthi\dataminingworkspace\Databasemining" workDir="D:\vasanthi\dataminingworkspace\Databasemining\work" >
< !--<Context path="/DBTest" docBase="DBTest"<br /> debug="5" reloadable="true" crossContext="true">-->



<Resource name="jdbc/TestDB"<br /> auth="Container"<br /> type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

< !-- Maximum number of dB connections in pool. Make sure you<br /> configure your mysqld max_connections large enough to handle<br /> all of your db connections. Set to 0 for no limit.<br /> -->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>

< !-- Maximum number of idle dB connections to retain in pool.<br /> Set to 0 for no limit.<br /> -->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>

< !-- Maximum time to wait for a dB connection to become available<br /> in ms, in this example 10 seconds. An Exception is thrown if<br /> this timeout is exceeded. Set to -1 to wait indefinitely.<br /> -->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

< !-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>root</value>
</parameter>

< !-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
what may be the possible fault.i have included all the jars ie commons.commons-dbcp-1.2.2,jdm jar,mysql jar and all.
its urgent.please reply for this request.thanks in advance.
ramya narayanan
Ranch Hand

Joined: Oct 06, 2008
Posts: 338
where is my original topic here?
A layman's doubt on build
Paul Yule
Ranch Hand

Joined: May 12, 2008
Posts: 229
it ended up being moved to the Ant/Maven/Other build tools forum instead of where the link sent us. I don't know if the error can be fixed.

P.S. Vasanthi: Sorry for the hi-jack.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: datamining jndi connection