LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-30-2021, 03:40 AM   #1
kzo81
Member
 
Registered: Aug 2014
Location: Hungary
Distribution: Debian, Linux Mint, CentOS
Posts: 197

Rep: Reputation: Disabled
traccar - H2 database - python connection


Hi,

I'm running Traccar in docker and I'd like to connect to its H2 database within the container.

this is my initial code:

Code:
import jaydebeapi


conn = jaydebeapi.connect("org.h2.Driver",
                           "jdbc:h2:/home/user/Documents/traccar/target/database",
                           ["sa", ""],'/usr/local/openjdk-11')
curs = conn.cursor()
conn.close()
this is the error message:

Code:
  File "dbmanager.py", line 5, in <module>
    ["sa", ""])
  File "/usr/local/lib/python3.7/dist-packages/jaydebeapi/__init__.py", line 412, in connect
    jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
  File "/usr/local/lib/python3.7/dist-packages/jaydebeapi/__init__.py", line 221, in _jdbc_connect_jpype
    jpype.JClass(jclassname)
  File "/usr/local/lib/python3.7/dist-packages/jpype/_jclass.py", line 99, in __new__
    return _jpype._getClass(jc)
TypeError: Class org.h2.Driver is not found
I also tried to initialise it with "com.mysql.cj.jdbc.Driver" however I couldnt establish connection.

Could you please help me?

Last edited by kzo81; 10-01-2021 at 01:33 PM.
 
Old 10-01-2021, 01:21 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,978

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
https://stackoverflow.com/questions/...t-python-to-h2
based on this your last argument is incorrect
 
2 members found this post helpful.
Old 10-01-2021, 01:32 PM   #3
kzo81
Member
 
Registered: Aug 2014
Location: Hungary
Distribution: Debian, Linux Mint, CentOS
Posts: 197

Original Poster
Rep: Reputation: Disabled
Yes, thanks, this is how it works

Code:
conn = jaydebeapi.connect('org.h2.Driver', 'jdbc:h2:/home/user/Documents/traccar/target/database', ["sa", ""], '/opt/traccar/lib/h2-1.4.200.jar')
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I got error while installing python-tk python-psycopg2 python-twisted saili kadam Linux - Newbie 1 09-05-2015 03:03 AM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
Database Programming (database to database transaction) johncsl82 Programming 7 02-02-2007 08:20 AM
LXer: A database solution is more than database software LXer Syndicated Linux News 0 09-25-2006 08:54 AM
Snort database: Closing connection to database "" Homer Glemkin Linux - Security 2 07-14-2005 06:58 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration