Unsolved What is the equivalent code lines to interbase jdbc url?
-
I checked the link you provided, but what is the value for provider in my case? I just used the default interbase driver in QT.
Thanks!
-
I think it's either
sibprovider
orSIBPROvider.2
-
I just tried to modify code as below:
QSqlDatabase db = QSqlDatabase::addDatabase("QIBASE", "ib"); db.setHostName("127.0.0.1"); QString connectionStr = "provider=SIBPROvider.2;location=localhost:;data source=c:\FOODBEV.GDB;user id=SYSDBA;Password=masterkey;character set=GB2312;"; // db.setDatabaseName("C:/FOODBEV.GDB");//"C:/TEST.GDB" db.setDatabaseName(connectionStr);//"C:/TEST.GDB" db.setUserName("SYSDBA"); db.setPassword("masterkey"); db.setConnectOptions("ISC_DPB_LC_CTYPE=GB2312"); // 对中文的支持 bool bopen = false; bopen = db.open(); LOG(TRACE) << "bopen=" << bopen;
And got below result output:
... bopen=0 QSqlQuery::exec: database not open ...
Using sibprovider or SIBPROvider.2 got the same result, which seems got open db failed issue. Or is there anything I did wrong regarding connectionStr ?
Thanks for kind help!
-
Looks like the connection string from https://www.connectionstrings.com/ is for ODBC driver connection? Not sure if the QT default Interbase driver is ODBC type?
Thanks again for kind help!
-
@xeoshow Use http://doc.qt.io/qt-5/qsqldatabase.html#lastError to print out the error after open().
And putting DB file in c:\ like c:\FOODBEV.GDB isn't a good idea as non-administrator users normally do not have write access there. -
@jsulm Thanks v much for help!
I moved the gdb database file to D:, and also used the lastError() method, now code as below:QSqlDatabase db = QSqlDatabase::addDatabase("QIBASE", "ib"); db.setHostName("127.0.0.1"); QString connectionStr = "provider=SIBPROvider.2;data source=D:/FOODBEV.GDB;character set=GB2312;"; db.setDatabaseName(connectionStr);//"C:/TEST.GDB" db.setUserName("SYSDBA"); db.setPassword("masterkey"); db.setConnectOptions("ISC_DPB_LC_CTYPE=GB2312;"); // 对中文的支持 bool bopen = false; bopen = db.open(); LOG(TRACE) << "bopen=" << bopen << ", lastError=" << db.lastError().text();
And still the same issue, got below LOG info, seems strange ...
bopen=0, lastError=Unable to complete network request to host "provider=SIBPROvider.2;data source=D". - Failed to locate host machine. - The specified name was not found in the hosts file or Domain Name Services. Error opening database QSqlQuery::exec: database not open
-
@xeoshow I never used Interbase but are you sure that Interbase uses a DB file like SQLite?
The error message tells you that it tries to connect to a computer over network.
You probably need to connect to an Interbase SERVER not file. -
@xeoshow Connection strings used here http://docwiki.embarcadero.com/InterBase/XE7/en/Connecting_to_InterBase_from_Visual_Studio look different to what you do.
-
BTW, using "D:/FOODBEV.GDB" or "D:\FOODBEV.GDB" got the same result ...
-
@jsulm Actually used my original code at the first post, I can insert data into the interbase, just can not select data with Chinese characters correctly...
The connection string is just got from https://www.connectionstrings.com/ , I will now try the one you provided. -
Seems still the same problem, anywhere I could check the qt source code to find the related logic?