Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environ
I'm pretty sure you already know this but unfortunately Jython can't load c extension modules.