[jboss-user] [Installation, Configuration & DEPLOYMENT] - Re: Problem with connecton pooling in JBOSS 4.2.2GA
priyarao234
do-not-reply at jboss.com
Fri Jun 20 01:07:06 EDT 2008
thankQ kiran 4 ur fast reply but, already i configured mysql-ds.xml filr as shown bellow..
mysql-ds.xml
<local-tx-datasource>
<jndi-name>DefaultDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/jmsDB</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
root
<max-pool-size>50</max-pool-size>
<min-pool-size>10</min-pool-size>
.....
.....
and as part of my progrm my code is as follows
package com.v2.util;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class DBConnFactory
{
static Connection con=null;
@SuppressWarnings("unchecked")
public static Connection getConnection() throws NamingException, SQLException
{
InitialContext ic = null;
DataSource ds = null;
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,
"=org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
ic = new InitialContext(env);
ds=(DataSource)ic.lookup("java:/DefaultDS");
con = ds.getConnection();
return con;
}
public static void main(String[] args) {
try {
System.out.println("connection---"+ DBConnFactory.getConnection());
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
But whole running my progrm it showing the following error
javax.naming.NameNotFoundException: DefaultDS not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.v2.util.DBConnFactory.getConnection(DBConnFactory.java:28)
at com.v2.util.DBConnFactory.main(DBConnFactory.java:35)
now u tell me how can i cross this....
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4159433#4159433
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4159433
More information about the jboss-user
mailing list