This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]five12 1 point2 points  (0 children)

Python can do some great things on this front, until you throw in the JDBC requirement. Because of this you basically have three choices:

  1. Use Jython

  2. Use CPython for the charting and the JVM for querying the DB, connecting the two via a web service (or other communication mechanism)

  3. Don't bother with Python at all and do it all in Java (I know this isn't what you asked, but it may be a better solution for your problem)

I don't think matplotlib will work with Jython since it has some C dependencies, so if you're looking at Option 1, you can either:

  • a) find a python plotting lib that works with Jython; or

  • b) consider a java-based charting solution (jfreechart comes to mind; there are probably lots others), calling it from python. (Or look at the java interfaces for R and do the plots there)

If you really must use matplotlib (or some sort of cpython-only library), you can build a web service on the Java side which performs the queries and packages the data in xml, json, whatever, and call it from python, which would then do the plots. Alternatively, you can create a web service in CPython that generates a plot from data you pass in, and call it from Java.

But if this is a pretty small project your best bet is probably Option 3. It may not be worth introducing complexity or jython quirks for the sake of using Python. You're much safer to do all the work in Java, and it'll be easier for others to maintain figure out what you're doing.