public static void main(String Data[])
{
ConnectionPoolDataSource dps;
try
{
cnt=new InitialContext();
cnt.rebind("java:comp/env/jdbc/pool/dragon", dps);
} '
catch (NamingException ex)
{
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
}
}
Following is my program to bind a ConnectionPoolDataSource object connect a database in mysql using JNDI.
On compiling it, i’ve got an error:
Exception in thread “main” java.lang.IllegalArgumentException: RegistryContext: object to bind must be Remote, Reference, or Referenceable
Now i’ve got the following doubts:
- How can i create a remote object for connecting to mysql database ?
- How can i assign the database name…etc…to that remote object ?
the ConnectionPoolDataSource does not provide method for setting server name, database name, etc.
It seems like u r trying to bind it using JNDI naming……
i suggest you something…
try c3p0 pooling….which would be easier for u…..
u can avoid using JNDI naming…..
read the tutorials from the following link and u can download the jar file…..
http://www.mchange.com/projects/c3p0/