can't make JNDI to work w/ jython/django

50 views
Skip to first unread message

Aljoša Mohorović

unread,
Jul 23, 2012, 1:15:18 PM7/23/12
to ibm...@googlegroups.com
i'm getting an error when i try to use JNDI but it works when i'm
connecting directly to database.
it looks like JNDI configuration is ignored, error is:
"""
ImproperlyConfigured at /
Please specify the valid database Name to connect to
"""

JNDI is valid because spring/hibernate app i'm porting to
jython/django is using it w/o issues.
i have something like this in my settings.py:

DATABASE_ENGINE = 'ibm_db_django'
if os.environ.get("DEV_MODE"):
DATABASE_NAME = 'MYDB'
DATABASE_USER = 'aljosa'
DATABASE_PASSWORD = 'aljosa'
DATABASE_HOST = '10.0.2.120'
DATABASE_PORT = '50000'
else:
DATABASE_OPTIONS = {
'JNDI_NAME': 'java:jdbc/MYDATASOURCE',
}

software versions:
Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
Django 1.1.4
django-jython 1.1.1
ibm_db_django 1.0.4

Aljosa

Rahul

unread,
Jul 24, 2012, 2:59:00 AM7/24/12
to ibm...@googlegroups.com

Hi Aljosa,
  JNDI lookup currently doesn't supported by our adaptor, this feature is in our TODO list.

Thanks,
Rahul

Aljoša Mohorović

unread,
Jul 24, 2012, 6:00:13 AM7/24/12
to ibm...@googlegroups.com
On Tue, Jul 24, 2012 at 8:59 AM, Rahul <rahul.pr...@in.ibm.com> wrote:
> JNDI lookup currently doesn't supported by our adaptor, this feature is in
> our TODO list.

but it's partially implemented?
if i specify database name it works so i guess JNDI is used somehow?
i need JNDI so i'm going to try to implement it, any idea what would
be the best place to start?
i'm thinking to start w/ django-jython code and do some copy/paste.

Aljosa
--
https://twitter.com/maljosa
https://github.com/aljosa

Rahul

unread,
Jul 25, 2012, 7:14:28 AM7/25/12
to ibm...@googlegroups.com

Hi Aljosa,
  JNDI support doesn't partially implemented in ibm_db_django, but there should not be more code changes required for this.
 For this, changes required in the jybase.py file's "_cursor" method, we are using zxJDBC package to use JDBC APIs so, you can take help from  http://wiki.python.org/jython/UserGuide#using-a-jndi-lookup to add this feature in ibm_db_django.

Thanks,
rahul

On Tuesday, July 24, 2012 3:30:13 PM UTC+5:30, Aljoša Mohorović wrote:

Aljoša Mohorović

unread,
Jul 25, 2012, 9:20:58 AM7/25/12
to ibm...@googlegroups.com
what i'm actually asking regarding schema is where would be the best
place to put something like:
"SET CURRENT SCHEMA = 'MY_APP_SCHEMA'"?

Aljosa

Aljoša Mohorović

unread,
Jul 25, 2012, 9:01:55 AM7/25/12
to ibm...@googlegroups.com
On Wed, Jul 25, 2012 at 1:14 PM, Rahul <rahul.pr...@in.ibm.com> wrote:
> JNDI support doesn't partially implemented in ibm_db_django, but there
> should not be more code changes required for this.
> For this, changes required in the jybase.py file's "_cursor" method, we are
> using zxJDBC package to use JDBC APIs so, you can take help from
> http://wiki.python.org/jython/UserGuide#using-a-jndi-lookup to add this
> feature in ibm_db_django.

thanks for information, could you point me where i should change some
code to force a specific schema to be used?
currently, if i'm connecting w/ user DB2INST1 my schema is DB2INST1
but i need to use a different schema.

Aljosa

Rahul

unread,
Jul 26, 2012, 6:04:18 AM7/26/12
to ibm...@googlegroups.com
Hi Aljosa,
If you wants to change current schema for whole application then you need to modify jybase.py, at line #43 we are creating connection string there you can modify connection string like
jdbc:db2://<HOST>:<PORT>/<DATABASE>:currentSchema=<SCHEMA>;.

In other option please look the discussion thread https://groups.google.com/forum/?hl=en_US&fromgroups#!searchin/ibm_db/django,$20schema/ibm_db/RxRwzXo7a_U/DSsL6xcD3SYJ

Thanks,
Rahul

On Wednesday, July 25, 2012 6:31:55 PM UTC+5:30, Aljoša Mohorović wrote:
Reply all
Reply to author
Forward
0 new messages