You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tommy Chheng <to...@gmail.com> on 2010/12/08 19:34:45 UTC

JDBC connection

I'm trying to register a jdbc connection.
The camel docs say to do:

JndiRegistry reg =super.createRegistry();
reg.bind("testdb", ds);
return  reg;

What's the super object referring to?

I'm trying to do:
     val dataSource = new MysqlConnectionPoolDataSource()
     dataSource.setUser("root")
     dataSource.setServerName("localhost")
     dataSource.setPort(3306)
     dataSource.setDatabaseName("test")
     val context = new DefaultCamelContext
     val reg = new JndiRegistry(context)
     reg.bind("test", dataSource)

but I'm running into this error:
  InvocationTargetException: javax.naming.NoInitialContextException: 
Need to specify class name in environment or system property, or as an 
applet parameter, or in an application resource file:  
java.naming.factory.initial

Isn't the initial context the defaultCamelContext?

-- 
@tommychheng
http://tommy.chheng.com


Re: JDBC connection

Posted by Tommy Chheng <to...@gmail.com>.
I was able to workaround this issue using the simpleRegistry
     val reg = new SimpleRegistry
     reg.put("test", dataSource)
     val context = new DefaultCamelContext(reg)

@tommychheng
http://tommy.chheng.com


On 12/8/10 10:34 AM, Tommy Chheng wrote:
> I'm trying to register a jdbc connection.
> The camel docs say to do:
> JndiRegistry reg =super.createRegistry();
> reg.bind("testdb", ds);
> return  reg;
> What's the super object referring to?
>
> I'm trying to do:
>     val dataSource = new MysqlConnectionPoolDataSource()
>     dataSource.setUser("root")
>     dataSource.setServerName("localhost")
>     dataSource.setPort(3306)
>     dataSource.setDatabaseName("test")
>     val context = new DefaultCamelContext
>     val reg = new JndiRegistry(context)
>     reg.bind("test", dataSource)
>
> but I'm running into this error:
>  InvocationTargetException: javax.naming.NoInitialContextException: 
> Need to specify class name in environment or system property, or as an 
> applet parameter, or in an application resource file:  
> java.naming.factory.initial
>
> Isn't the initial context the defaultCamelContext?
>
> -- 
> @tommychheng
> http://tommy.chheng.com