Tag Archives: sql

How to work with SQL in C++ and Qt

You can work with SQL queries in Qt and SQL in many different ways, here I will show you how I came up with a working method. To keep things simple, I am not going to use any UI to print or edit queries. It will be just source code and stdout, as a database engine I will use SQLite3.

After you created your project, edit project.pro and locate line:

QT       += core

Modify this line by adding `sql`:

QT       += core sql

Since now, when you compile your project, QtSql module will be linked to the project:

g++ -Wl,-O1 -Wl,-O1,--sort-common,--as-needed,-z,relro -o QtSql main.o   -lQt5Sql -lQt5Core -lpthread

Continue reading

Copy one table from one database to another and replace values in one of the columns

This blog is also available in .onion domain. Both blogs have different databases, DB users and passwords, different WordPress configurations, and as a result, they have different data in DB column.

After publishing a new post here, I do not want to manually copy posts from here to there and I want images from b.agilob.net to be available in .onion to avoid any clearnet connections. To do so, the content of each post must be scanned for ‘/‘ and this string must be replaced with ‘http://agiloblulimjeqlq.onion/‘.

Continue reading

Solution to SQLException: No suitable driver found for jdbc:mysql

Just a quick fix.

Instead of:

Connection con = null;
 
String url = "jdbc:mysql://localhost:3306/mysql";
String user = "user";
String password = "password";
con = DriverManager.getConnection(url, user, password);

You should have:

Connection con = null;
 
String url = "jdbc:mysql://localhost:3306/mysql";
String user = "user";
String password = "password";
 
try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
    System.err.println(ex.getMessage());
}
con = DriverManager.getConnection(url, user, password);

Continue reading

[pl] Learn IT online – zestaw kursów do nauki informatyki

[pl] Gynvael Coldwind prowadzi swoje kursy na YT. RE, debugging, Asm, programowanie OO widziane z niska. Czekam na OpenGL.

[pl] javastart.pl Kurs Javy, wstęp do programowania w Javie na Android i co nieco JEE. Autor ma dobre nawyki pisania w OO.

Continue reading