Postgresql connection from Jython not working for me

147 views
Skip to first unread message

JC11

unread,
Apr 8, 2010, 1:37:55 PM4/8/10
to web2py-users
The next Jython challenge !

The line:
db = DAL('postgres://stubo:st...@10.220.17.77/stubo_remote',
pool_size=10)
works fine when running in python, but fails from Jython (see
below).

From Jython I can run: 'from com.ziclix.python.sql import zxJDBC', so
I think that is installed OK


Traceback (most recent call last):
File "C:\web2py1_76_5\gluon\restricted.py", line 173, in restricted
exec ccode in environment
File "C:/web2py1_76_5/applications/stubo/models/db.py", line 27, in
<module>
db = DAL('postgres://stubo:st...@10.220.17.77/stubo_remote',
pool_size=10)
File "C:\web2py1_76_5\gluon\sql.py", line 3782, in DAL
return SQLDB(uri, pool_size=pool_size, folder=folder,
File "C:\web2py1_76_5\gluon\sql.py", line 1161, in __init__
self._pool_connection(lambda
params=params:zxJDBC.connect(*params))
File "C:\web2py1_76_5\gluon\sql.py", line 840, in _pool_connection
self._connection = f()
File "C:\web2py1_76_5\gluon\sql.py", line 1161, in <lambda>
self._pool_connection(lambda
params=params:zxJDBC.connect(*params))
IndexError: index out of range

Any suggestions welcome.

John C.

mdipierro

unread,
Apr 8, 2010, 2:20:15 PM4/8/10
to web2py-users
This was never tested and if you help we can get it to work today.

In sql.py try replace line

params = ('jdbc:postgresql://%s:%s/%s' % (host, port, db),
user,passwd)

with

params = ('jdbc:postgresql://%s:%s/%s' % (host, port, db),
user,passwd, 'org.postgresql.Driver')

John Cobo

unread,
Apr 8, 2010, 4:54:42 PM4/8/10
to web...@googlegroups.com
Hello,

 I have made the suggested change to sql.py.  The result is below.

Traceback (most recent call last):
File "C:\web2py1_76_5\gluon\restricted.py", line 173, in restricted
exec ccode in environment
File "C:/web2py1_76_5/applications/stubo/models/db.py", line 27, in <module>
db = DAL('postgres://stubo:st...@10.220.17.77/stubo_remote', pool_size=10
)
File "C:\web2py1_76_5\gluon\sql.py", line 3784, in DAL
return SQLDB(uri, pool_size=pool_size, folder=folder,
File "C:\web2py1_76_5\gluon\sql.py", line 1163, in __init__

self._pool_connection(lambda params=params:zxJDBC.connect(*params))
File "C:\web2py1_76_5\gluon\sql.py", line 840, in _pool_connection
self._connection = f
()
File "C:\web2py1_76_5\gluon\sql.py", line 1163, in <lambda>
self._pool_connection(lambda params=params:zxJDBC.connect(*params))
DatabaseError: driver [org.postgresql.Driver] not found

Does that help ?

John C.

--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.

mdipierro

unread,
Apr 8, 2010, 6:12:01 PM4/8/10
to web2py-users
does this help?

http://stackoverflow.com/questions/468763/how-to-connect-to-database-from-jython

On Apr 8, 3:54 pm, John Cobo <john.c...@gmail.com> wrote:
> Hello,
>
>  I have made the suggested change to sql.py.  The result is below.
>
> Traceback (most recent call last):
>   File "C:\web2py1_76_5\gluon\restricted.py", line 173, in restricted
>     exec ccode in environment
>   File "C:/web2py1_76_5/applications/stubo/models/db.py"
> <http://127.0.0.1:8000/admin/default/edit/stubo/models/db.py>, line
Reply all
Reply to author
Forward
0 new messages