I followed this tutorial to compile mysql driver with VS2010 :
Qt - How to get|compile Mysql driver.
The compilation fails with the error : LNK1123: failure during conversion to COFF: file invalid or corrupt
I tried with with multiple versions of mysql and qt, i always get the same error.
Note: I am using Qt-4.8.4 and mysql-5.5.32-win32.
I would rebuild Qt from source, because you also need the SQL driver (not only the plugin).
The driver source is located under /src/sql/drivers/mysql
The plugin source is located under /src/plugins/sqldrivers
/src/sql/drivers/mysqldrivers.pri contains this:
contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase
contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri)
So I think that you need to run configure with the options: -qt-sql-mysql and -plugin-sql-mysql before compiling Qt.
Recompile Qt
Open a Qt 4.8.4 Command Prompt
cd \qtdir
nmake distclean
configure -debug-and-release -platform win32-msvc2010 -mp -nomake examples -nomake demos -qt-sql-mysql -plugin-sql-mysql
nmake
You might need to point configure to the correct include/library directory for MySQL, by adding this options: -I "c:\path\to\mysql\include" and -L "c:\path\to\mysql\lib"
Related
i'am using a Windows x64, i need to use Mysql 8 in QT 5.14.2( MinGW x64)
i've started installing MySQl driver as indicated :
2- then when, I am using:
cd $QTDIR/qtbase/src/plugins/sqldrivers/mysql
3- and run:
qmake -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Server 8.0\include" "MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Server 8.0\lib"
I'm getting :
Project ERROR: Library 'mysql' is not defined.
in the log file it shows me that there's a missing file sybfront.h anyone knows how to solve this please
You should replace '\' by '/', either paths will be invalid, even on Windows.
And one quote " is not closed in your code.
qmake parameters follows the same rules as pro file contents:
https://doc.qt.io/qt-5/qmake-project-files.html
I'm porting my project from qt4.8.4 on windows server 2003(32bit) to qt5.3.1 on win7(64bit), I build qt source statically, and build qsqlmysql dynamically, but my code can not load mysql qt driver. The error is like follows,
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:()
My code is as follows,
db = QSqlDatabase::addDatabase("QMYSQL", "*****");
db.setHostName("*****");
db.setDatabaseName("*****");
db.setUserName("*****");
db.setPassword("*****");
When I search "QMYSQL" in registry, I get nothing, it seems qmysql driver is not registered.
Any ideas?
A default configuration will only give you sqlite support, maybe ODBC will be auto-detected on windows. You will need to specify sql support and possibly provide libs and include paths too. For example (using mardiadbclient for mysql):
Pre Qt 5.8:
-qt-sql-mysql -L E:\msys64\mingw64\lib -l mysqlclient -I E:\msys64\mingw64\include\mariadb
Post Qt 5.8:
-sql-mysql MYSQL_INCDIR=E:\msys64\mingw64\include\mariadb MYSQL_LIBDIR=E:\msys64\mingw64\lib MYSQL_LIBS="-l mysqlclient" -L
E:\msys64\mingw64\lib
in qt4.8.4, when you link qsqlmysql statically, you should write:
Q_IMPORT_PLUGIN(qsqlmysql)
but in qt5.3.1, the name changed, you should write the macro as following:
Q_IMPORT_PLUGIN(QMYSQLDriverPlugin)
That's why i always get a unresolved external... error. After change the name, i can link mysql successfully.
I want to create a database within a pipeline script to be used by the deployed app. But first I started testing the connection. I got this problem:
java.sql.SQLException: No suitable driver found for jdbc:mysql://mysql:3306/test_db
I have the database plugin and the MySQL database plugin installed.
How do I get the JDBC driver?
import groovy.sql.Sql
node{
def sql = Sql.newInstance("jdbc:mysql://mysql:3306/test_db", "user","passwd", "com.mysql.jdbc.Driver")
def rows = sql.execute "select count(*) from test_table;"
echo rows.dump()
}
Update after albciff answer:
My versions of:
Jenkins = 2.19.1
Database plugin = 1.5
Mysql database plugin = 1.1
The latest test script.
import groovy.sql.Sql
Class.forName("com.mysql.jdbc.Driver")
Which throws:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
From the MySQL DataBase Plugin documentation you can see that jdbc drivers for MySQL are included:
Note that MySQL JDBC driver is under GPLv2 with FOSS exception. This
plugin by itself qualifies under the FOSS exception, but if you are
redistributing this plugin, please do check the license terms.
Drizzle(+MySQL) Database Plugin is available as an alternative to this
plugin, and that one is under the BSD license.
More concretely the actual last version (1.1) for this plugin contains connector version 5.1.38:
Version 1.1 (May 21, 2016) mysql-connector version 5.1.38
So probably in order to have the driver available you have to force the driver to be registered.
To do so use Class.forName("com.mysql.jdbc.Driver") before instantiate the connection in your code:
import groovy.sql.Sql
node{
Class.forName("com.mysql.jdbc.Driver")
def sql = Sql.newInstance("jdbc:mysql://mysql:3306/test_db", "user","passwd", "com.mysql.jdbc.Driver")
def rows = sql.execute "select count(*) from test_table;"
echo rows.dump()
}
UPDATE:
In order to has the JDBC connector classes available in the Jenkins pipeline groovy scripts you need to update the DataBase plugin to last currently version:
Version 1.5 (May 30, 2016) Pipeline Support
You can simply add the java connector in the java class path.
If jenkins is running java < 9 you probably will find the right place inside something like that:
<java_home>/jre/lib/ext
If jenkins is running java >= 9 you probably will find the right place inside something like that:
/usr/share/jenkins/jenkins.war
To find your paths you can check:
http://your.jenkins.host/systemInfo (or navigate system info path by GUI) and search for java.ext.dirs or java.class.path
http://your.jenkins.host/script (running console script such as System.getProperty("java.ext.dirs") or System.getProperty("java.class.path"))
This snippet can help you with the jenkins.war thing when running inside docker:
#adding extra jars to default jenkins java classpath (/usr/share/jenkins/jenkins.war)
RUN sudo mkdir -p /usr/share/jenkins/WEB-INF/lib/
RUN whereis jar #just to find full jar command classpath to use with sudo
COPY ./jar-ext/groovy/mysql-connector-java-8.0.21.jar /usr/share/jenkins/WEB-INF/lib/
RUN cd /usr/share/jenkins && sudo /opt/java/openjdk/bin/jar -uvf jenkins.war ./WEB-INF/lib/mysql-connector-java-8.0.21.jar
For Jenkins running on Java >= 9 add the jdbc drivers under ${JENKINS_HOME}/war/WEB-INF/lib and under the --webroot directory.
Trying to install RMySQL on 64-bit Windows 7.
Using R-2.14.2 with Rtools214 and MySQL Server 5.5.
Read through several step-by-steps of RMySQL source installation.
Troubleshooting:
- Copied libmysql.dll to R-2.14.2/bin AND R-2.14.2/bin/i386.
- Copied libmysql.dll and libmysql.lib to MySQL Server 5.5\lib\opt.
- Entered MYSQL_HOME=C:\Program Files\MySQL\MySQL Server 5.5 into Renviron.site, saved to R\R-2.14.2\etc.
My instances of common problems:
Sys.getenv('MySQL_HOME')
[1] "C:\Program Files\MySQL\MySQL Server 5.5\"
install.packages('RMySQL', type = 'source')
Installing package(s) ...
...
RS-DBI.c:1:0: sorry, unimplemented: 64-bit mode not compiled in
make: [RS-DBI.o] Error 1*
ERROR: compilation failed for package 'RMySQL'
...
I'm guessing my problem lies in the '64-bit mode...' message, but I'm not sure.
Thoughts?
I'm not sure this error message has anything to do with RMySQL, or any particular package.
On 64bit Windows, instead of the default PATH :
C:\Rtools\MinGW\bin
( gives the error sorry, unimplemented: 64-bit mode not compiled in )
you might (quite reasonably) notice the MinGW64 directory alongside and try :
C:\Rtools\MinGW64\bin
but in fact it needs to be :
C:\Rtools\gcc-4.6.3\bin
Then of course, stop and start a new DOS window to pick up the new PATH.
I had problems installing RMySQl
so I installed the package RODBC which works fine.
(make sure the MySQL driver is installed).
http://dev.mysql.com/downloads/connector/odbc/
On a centos,
qt creator 1.2.1
qtsdk-2009.04
what step by step is needed to create mysql driver, in linux and in windows.
such that running following command gives an positive output
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("xxxxxxxxxx");
db.setDatabaseName("xxxxxxxdb");
db.setUserName("xxxxxxxxxxx");
db.setPassword("xxxxxxxxxxx");
bool ok = db.open();
Brgds,
kNish
I used to have PostgreSQL(8.3) driver compiled successfully.Following is the batch cmds to do the job(replace the path with yours).
cd D:\SoftwareSetup\Dev\Qt\2009.05\qt\src\plugins\sqldrivers\psql
D:\SoftwareSetup\Dev\Qt\2009.05\qt\bin\qmake “INCLUDEPATH+=D:\SoftwareSetup\Dev\PostgreSQL\8.3\include” “LIBS+=D:\SoftwareSetup\Dev\PostgreSQL\8.3\lib\libpq.lib” psql.pro
#”D:\SoftwareSetup\Dev\Microsoft Visual Studio 9.0\VC\bin\nmake”
“D:\SoftwareSetup\Dev\Qt\2009.05\mingw\bin\mingw32-make”
pause
If you use VC compiler,use nmake to get it compiled,
and I also referenced to following two links to find out library dependency:
http://lists.trolltech.com/qt-interest/2006-11/thread00265-0.html
http://doc.trolltech.com/4.6/sql-driver.html#how-to-build-the-qdts-plugin-on-windows
This page from Nokia Qt doc may be helpful on *nix(and Windows):
http://doc.qt.nokia.com/4.6/sql-driver.html#supported-databases