> Date: Thu, 4 Apr 2002 15:21:07 +0800
> From: JavaSoft <[EMAIL PROTECTED]>
> Subject: Database Connection Problem
>
> Hi guys
> I have a problem connecting to database using
> datasource. I am trying to
> make simple application ( with j2se ). The program
> only list a table when i
> run it. Thats all.
> This is the method to create connection.
> private void makeConnection()
> {
> try
> {
> InitialContext ic = new InitialContext();
> System.out.println("LOOKUP");
> DataSource ds = (DataSource) ic.lookup(
> "java:comp/env/jdbc/corePool" );
> System.out.println("DSS " + ds);
> Connection con = ds.getConnection();
> }
> catch(Exception e)
> {}
> }
>
> There's no error .. but DataSource object is null.
> This simple program
> running together with SUN j2EE server in my local
> computer.
> Is there any setting that i should do ?
>
> ===
> thx,
> a Java Addicted
>
You are trying to do a lookup using the JNDI ENC
(Environment Naming Context). Is the JNDI bound
properly in your app server?
What type of application is it? For example, if you
are running this code under the app server as a
servlet, then you would have to add the entry to
web.xml
<resource-ref>
<res-ref-name>jdbc/corePool</res-ref-name>
</resource-ref>
If you are trying to connect from a simple client,
then you can package it within an ear and add the
above entry in the application.xml file.
Hope that helps.
- Richard
P.S. This is an EJB specific list, there are other
groups that are better suited to these types of questions.
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".