Creating JDBC driver in R using RJDBC - mysql

I am trying to create a JDBC driver in R using following code:
i have already set the directory to location where .jar folder is located
drv <- JDBC("com.mysql.jdbc.Driver",
"mysql-connector-java-3.1.14-bin-g.jar",
identifier.quote="`")
i get the following error:
Error in .jfindClass(as.character(driverClass)[1]) : class not found
what would be the problem?

the following works for me i.e. i do not get "class not found" error. I downloaded mysql-connector-java-5.1.38-bin.jar into my current working directory and ran the below without issues
library(RJDBC)
drv <- JDBC(driverClass="com.mysql.jdbc.Driver",
classPath="mysql-connector-java-5.1.38-bin.jar",
identifier.quote="`")

I had a problem loading the script drv <- JDBC("com.mysql.jdbc.Driver","PATH_to_jar", ...) in R, although the PATH was correct. There was a Java update in my Linux distro which caused the package rJava or RJDBC not to work anymore. Unfortunately, the error message was that class com.mysql.jdbc.Util could not be found when executing the subsequent dbConnect(drv, ...) after this update. This was a bit strange and took me a while to figure out that the package was broken, because it loaded correctly using library(RJDBC).
My solution was to reinstall rJava and RJDBC to make it work again (packages.install("rJava") packages.install("RJDBC")). I recognized it was a Linux problem since the code worked fine in RStudio on Windows.

Related

Package or namespace load failed for ‘RxODE’ .onAttach failed in attachNamespace() for 'RxODE',

I am trying to create a model simulation using RxODE, this R-code was successful previously on a colleague's computer. R was just reinstalled on the computer I am currently using (version 3.6.2). I continue to get this error...
Error: package or namespace load failed for ‘RxODE’:
.onAttach failed in attachNamespace() for 'RxODE', details:
call: !.rxWinRtoolsPath(retry = NA)
error: invalid argument type
I have tried .libPaths(.libPaths()[2]), reinstalling all my packages, and to install RxODE with dependencies=TRUE.
Any insight would be greatly appreciated.
https://github.com/cran/RxODE/issues/1#issuecomment-320900446
I had the same problem like you and could solve it with the description given in the link.
Or in other words, just try to run this code:
path <- Sys.getenv("PATH")
path <- c("C:\Rtools\bin", "C:\Rtools\gcc-4.6.3\bin", path)
path <- paste(path,collapse=";")
Sys.setenv(PATH=path)
Sys.getenv("PATH")
Best wishes

Unable to call apoc.load.json on Neo4j 3.2.6

I am using Neo4j Community Edition 3.2.6 along with apoc-3.2.3.5-all.jar on Mac. When I try to use any query on the browser that contains call apoc.load.json, I keep getting Failed to invoke procedure apoc.load.json: Caused by: java.lang.NoClassDefFoundError: Could not initialize class apoc.util.JsonUtil. I can confirm that Neo4j is able to find my jar under plugins directory as apoc.load.json is listed when I use CALL dbms.procedures(). Does anyone know what could possibly be wrong that I am getting the error?
I tried the same versions on my Mac, and could not reproduce that error.
If you installed the Neo4j Desktop for OSX, you need to put plugin jar files in 2 folders:
- /Applications/Neo4j\ Community\ Edition\ <version>.app/Contents/Resources/app/plugins
- /Users/<user>/Documents/Neo4j/default.graphdb/plugins

Broken MySql driver for PySide2 on Windows?

I've been forced to try to port to PySide2 from PySide because I'm developing code (on Windows 7) used inside Maya and Maya 2017 has moved to PySide2.
PySide2 ships with Maya but only comes with the driver to talk to sqlite DBs. So I need to tell Qt about a new DIR that contains the MySql driver, like this:
from PySide2 import QtWidgets
QtWidgets.QApplication.addLibraryPath("C:\temp\plugins")
This DIR contains a sub sqldrivers DIR which contains the driver. This works- when I call QtSql.QSqlDatabase.drivers() the new one is there so I've got the right driver and it's being picked up.
However when I create a new DB and call open:
db = QtSql.QSqlDatabase.addDatabase("QMYSQL3")
db.setDatabaseName("my_db")
db.setHostName("host")
db.setUserName("user")
db.setPassword("password")
db.open()
the open command returns False and the DB is not accessible. I call:
db.lastError()
and get:
# Result: <PySide2.QtSql.QSqlError("", "Driver not loaded", "Driver not loaded") at 0x0000000075410C08> #
NB: we successfully did the exact same thing with the previous PySide version.
Other threads mention similar things and it turned out to be missing the actual libmysql.dll, which is the actual MySql DLL and can result in the same error if missing. However I definitely have this on my system and it's definitely in the PATH. It's actually the same file that is being successfully picked up through PySide. But the PySide2 driver just wont open a connection to the DB.
I suspect maybe a dodgy driver but wondered if anyone has any experience with this or any advice?
I had the same error, but with postgres.
I solved by placing the libpq.dll connector library next to my script.py.
Then for mysql it would be libmysql.dll.
In my case I had to build the libpq.dll from the source of postgres 9.6
It seems that with PySide2 it is not necessary to use:
QtWidgets.QApplication.addLibraryPath ("C: \ path_to\ plugins")
using:
print (PySide2.QtCore.QLibraryInfo.location (PySide2.QtCore.QLibraryInfo.PluginsPath)), I could see that the path was correct.
a greeting

xcode: Mysql connector library not work on iphone5 (armv7s) ,any solution?

I built my App using Mysql Connector/C to connect a remote Mysql database, its works fine on the simulator (no errors, no warnings) but when i try to run it on my device (iphone5) i got this error:
No architectures to compile for (ARCHS=armv7 armv7s, VALID_ARCHS=armv7 armv7s)
i tried -as in some answers- to change setting (Architectures - Build Active Architectures- Valid Architectures) but the error still, only when i change the setting (Architectures & Valid Architectures) to "armv6" its build without error but many warnings appears says:
warning: no rule to process file '(my App dir)/main.m' of type sourcecode.c.objc for architecture armv6
and also for all .m files, when i tried to start the App i got message:
Xcode cannot run using selected device
I know that the Connector library need to update , but are there any solution ?
your need compile the connector lib in xcode for iOS (armv6, armv7, armv7s, i386), then use lipo tool to combine output libs.
direct connect your mysql in app is not safe, a suggest way is setup a Apache+PHP+MySQL server, then on iPhone useing ASIHTTPRequest to connect your server.

JDBC driver not found error in monkeyrunner/jython

I need to Insert something in the DB. im using JDBC as a connector, jython the script, mysql the DB and the script is running in CentOS.
my code looks something like this:
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
from com.ziclix.python.sql import zxJDBC
db=zxJDBC.connect("jdbc:mysql://XXX.XXX.XXX.XXX:3306/dbname","USER","PASSWORD","org.gjt.mm.mysql.Driver")
c=db.cursor() c.execute("INSERT INTO tablename values ('X','X','X')")
before that, I downloaded and decompressed the file from here (in the desktop)
I added the path to classpath by doing this
export PATH=/home/XX/Desktop/mysql-connector-java-5.1.22
and when I ran the script, it gave me this error
zxJDBC.DatabaseError.driver [org.gjt.mm.mysql.Driver] not found
what have I done wrong? is the name of the driver name correct? because I just copied it in one of the tutorials that I've seen. or probably did I install the driver correctly?
Thanks.
this is how I managed to solve the error:
Download the JDBC driver here
Extract the tar.gz file anywhere you want.
You will find mysql-connector-java-5.1.22-bin.jar inside that folder. Copy that and paste to (in my case) /%android-sdk%/tools/lib
Add the new location of mysql-connector-java-5.1.22-bin.jar to classpath
do the script like this
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,
MonkeyImage
from com.ziclix.python.sql import zxJDBC
db=zxJDBC.connect("jdbc:mysql://XXX.XXX.XXX.XXX:3306/dbname","USER","PASSWORD","com.mysql.jdbc.Driver")
c=db.cursor()
c.execute("INSERT INTO tablename values ('X','X','X')")
db.commit()
Hope this helps to those who will need it in the future. :)
How are you running jython? If you're using the standalone install, i.e. java -jar jython.jar, then from the Java Documentation ...
-jar
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
... you can't add anything to the classpath. Repackaging the required classes into the jython jar is one approach or this answer has an alternative solution - basically add the jython.jar to the classpath too (either using -cp or CLASSPATH) and run the org.python.util.jython class directly.
I got the sample problem in windows7,I slove this problem by this:
download the JDBC driver
add the mysql-connector-java-ver-bin.jar to envionment variables:
such as:
CLASSPATH : C:\xxx-path\mysql-connector-java-5.1.41-bin.jar
then I slove this problem