Topic: Zeos SQLite application «SQL Error: library routine called out of sequence» (Read 24694 times)
G’day one and all,
I’m developing a small sqlite application for windows 32 with the Zeos DB components. When I deploy my application onto any machine other than my development pc I get the above error on startup. I’m using Inno to create my setup file to deploy my application.
If run my application either via Lasarus IDE or I deploy my application locally via the setup file on my development machine It runs successfully, no problems here.
I thought it might be the sqlite3.dll location, currently I package the dll and it gets installed in the applications installation directory, right next to the .exe. I’ve also tried copying the dll to system32 folder, but no difference.
At the moment My application is basically a skeleton that shows existing data from the database file in tables, it has one active TZConnection and a few active TZTables that I set at run time, these are linked via their relavant datasets to my visual DB components, as I mentioned, all works on my development machine when executed, just not on any other.
I though it may be the application not able to locate the db file, but I set the file path at runtime and I can confirm it’s locating the correct database file at run time on my development machine from it’s deployed directory.
My current test setup is a virtual stock standard windows XP SP3 install, I’ve also tried installing on a seperate physical PC, same error reported on both.
Regards,
Stephen…
Logged
Is the sqlite3.dll compiled by youself?
Logged
If it is compiled by VC, the runtime library should be installed.
Logged
No the dll is the pre-compiled binary direct from the sqlite d/l site
Logged
If it is compiled by VC, the runtime library should be installed.
Ok that makes sense, I’ll need to check how it has been compiled. What does everyone else use for their pre-compiled DLL, is there a statically linked version without the need to re-distribting the VC runtimes?
I’ll try installing the VC runtimes to see if it resolves the error, then take it from there.
Cheers,
Stephen…
« Last Edit: February 10, 2011, 12:53:18 am by seaton »
Logged
Just tried the VC runtimes installed on my test machine and makes no difference.
stephen…
Logged
Logged
Is the installation path the full alphanumeric letters.
Logged
Is there thread in the program? Did you try Lazarus local database component?
http://www.sqlite.org/cvstrac/wiki?p=LibraryRoutineCalledOutOfSequence
No threading enabled, I have a single TZConnection pointing to the database anbd 8 TZTables pointing to the relevant tables, on my form I have grids using datasources that have these tables as their datasets, no custom SQL queries at the moment as Its really just a skeleton at the moment with basic functionality.
All these controls reside in a datamodule which is the first form to be loaded, the next is my main form, every other form is non-autoload.
From the few bits of information I could find on google relating to this error there seem to be some problems in a transaction not commiting after, while I don’t have any transactions I have disabled the autocomit on the TZConnection to see if it made a difference, still the same problem.
I havent tried the lazarus local database component, but will do after I finish this post. The strange thing is that it all works on my development machine, your previous post about the VC runtimes made sense as I would have these installed on my development machine and not on my test machine, it’s as though something is missing from my test machine.
Stephen…
« Last Edit: February 10, 2011, 08:27:02 am by seaton »
Logged
Is the installation path the full alphanumeric letters.
yes fairly straight forward c:program filesmyapp
Logged
Ok I have solved this problem after much head scratching….
I ended up creating a completly new app and used this as a basis to find the problem.
Initially I received the exact same problem on the single table app where I intentionally did not put in my database onCreate code where I set the database file location and then connect.
I then copy and pasted the code from my non working application, low and behold the test app started working.
ZRallylogDB.Database := ExtractFilePath(Application.ExeName) + 'dbrallylog.s3db';
ZRallylogDB.Protocol := 'sqlite-3';
ZRallylogDB.Connect;
If the code is exactly the same then it had something to do with my project so I then double checked my projects options against my working test and there were a couple of settings here that were different so I corrected.
After recompiling I then started receiving the same error code in my development environment as I did on my test machine when running the installed application, which made everything easy to find. I just put a breakpoint on my database intialiazation code.
In the end the error I was getting was to do with TZConnection component being enabled at design time and my designtime database files selected in the component, even though I was setting up the connection in my applications dataforms onCreate method, it appears it was tring to to connect to the non existant database file when the form was created, before the onCreate, so I had to disable my TZConnection at design time (along with my compiler settings) now all appears to be working on my deployment test machine.
Stephen…
Logged
In the end the error I was getting was to do with TZConnection component being enabled at design time and my designtime database files selected in the component, even though I was setting up the connection in my applications dataforms onCreate method, it appears it was tring to to connect to the non existant database file when the form was created, before the onCreate, so I had to disable my TZConnection at design time (along with my compiler settings) now all appears to be working on my deployment test machine.
Thanks for the detailed feedback. It will make things easier for other people in the future.
Actually I also had this problem when I started with Zeos (but then with postgresql), but I didn’t connect the dots till your feedback. It might be wise to propagate such info back to ZEOS for their FAQs.
Logged
Thanks for the detailed feedback. It will make things easier for other people in the future.
Actually I also had this problem when I started with Zeos (but then with postgresql), but I didn’t connect the dots till your feedback. It might be wise to propagate such info back to ZEOS for their FAQs.
Will do
Actually upon reading some of the ZeosLib api docs, it appears the DesignConnection in the TZTable component when enabled will disable the connection on recompile so this sort of thing won’t happen.
« Last Edit: February 11, 2011, 08:28:17 am by seaton »
Logged
Sorry to revive this old post, but i’ve created an app that worked fine, then moved the entire folder to another path and the app starts to giving this error («SQL Error: library routine called out of sequence» ).
After long head scratch and reading this post, clicked the tzconnection component and realise that the path for the database was wrong (was pointing to the old path) in the database property.
Removed all the path and just leaved the name of the file of database and worked again.
Maybe this is useful for somebody.
Logged
I released a version on July 23rd with SQLCipher 3.5.2
Eight different devices reported this error in the past couple of days.
Galaxy Core Prime (cprimeltemtr) 5.1
Galaxy Tab A 9.7 (gt510wifi) 6.0
Galaxy J7(2016) (j7eltetmo) 6.0
Galaxy S7 Active (poseidonlteatt) 6.0
LG G5 (h1) 6.0
Galaxy S7 Edge (hero2lte) 5.1
Galaxy S6 (zerofltespr) 6.0
Moto G (3rd Gen) (osprey_u2) 6.0
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: net.sqlcipher.database.SQLiteMisuseException: library routine called out of sequence: , while compiling: SELECT * FROM h_entries WHERE chapterID=? ORDER BY _id
at net.sqlcipher.database.SQLiteCompiledSql.native_compile(SQLiteCompiledSql.java)
at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:83)
at net.sqlcipher.database.SQLiteQuery.<init>(SQLiteQuery.java:49)
at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1762)
at net.sqlcipher.database.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1624)
at net.sqlcipher.database.SQLiteDatabase.query(SQLiteDatabase.java:1576)
at net.sqlcipher.database.SQLiteDatabase.query(SQLiteDatabase.java:1665)
at org.blueletterbible.blb.DataBaseHelper.fetchHighlightsByChapter(DataBaseHelper.java:681)
I’m using your typical singleton approach
public class DataBaseHelper extends SQLiteOpenHelper {
public static synchronized DataBaseHelper getInstance(Context context, String dbName) {
DataBaseHelper sInstance;
mContext = context.getApplicationContext();
if(sInstances.containsKey(dbName)) {
sInstance = sInstances.get(dbName);
if (sInstance == null) {
sInstance = new DataBaseHelper(mContext, dbName);
sInstances.put(dbName, sInstance);
}
} else {
sInstance = new DataBaseHelper(mContext, dbName);
sInstances.put(dbName, sInstance);
}
return sInstance;
}
public Cursor fetchHighlightsByChapter(int chapterID) {
String[] whereArgs = {Integer.toString(chapterID)};
openDb();
return db.query(H_ENTRIES, new String[]{"*"}, KEY_CHAPTERID+"=?", whereArgs, null, null, KEY_ROWID);
}
This is the first of this kind after releasing with 3.5.2
Unfortunately, I’ve not run into this myself. These are reports from the wild and as such I don’t have a way to replicate the problem, nor run the test suite on them. I’m hoping that since the error is right from sqlcipher, that you might be able to shed some light on it. Our app has never even experienced an error from your library until I bumped up to 3.5.2 from 3.4.0.
I saw this error happen exactly once when I was testing some changes last year and reported it in #176.
I am almost positive that this is triggered by the sqlite3_prepare16_v2()
call in net_sqlcipher_database_SQLiteCompiledSql.cpp
. I found an excellent reference at: http://stackoverflow.com/questions/8372871/library-routine-called-out-of-sequence-sqlite3-prepare-v2create-table
I have worked quite a bit with the code in this project and there are plenty of guards against using sqlite3_prepare16_v2()
among other sqlite3 calls on invalid database handles. I am wondering if this may be due to concurrency issues, i.e. «Trying to use the same database connection at the same instant in time from two or more threads.».
If this is the case, I wonder if we should use locking to ensure this does not happen?
Hi @brodybits, @theBlbDan,
Thank you for your feedback. I would like to see if we can recreate the issue before we attempt to resolve it by making changes to the code. @theBlbDan if there is any additional information you think you can share regarding the scenario including the query, schema, setup we would like to look into this further. Thanks!
Hi @developernotes, agreed.
Assuming I am right that this is a problem due to concurrency, it should be possible to use synchronized
methods or blocks in the application code to prevent this from happening. Just an idea.
I’m not sure how related this might be, but here’s another issue since bumping up to 3.5.2 from 3.4.0.
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalStateException: database not open
at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1760)
at net.sqlcipher.database.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1634)
at net.sqlcipher.database.SQLiteDatabase.query(SQLiteDatabase.java:1586)
at net.sqlcipher.database.SQLiteDatabase.query(SQLiteDatabase.java:1675)
at org.blueletterbible.blb.DataBaseHelper.fetchHighlightsByChapter(DataBaseHelper.java:711)
highlights.blb schema.
CREATE TABLE [highlights] (
[_id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[h_name] TEXT NOT NULL,
[h_alpha] CHAR(2) NOT NULL,
[h_red] CHAR(2) NOT NULL,
[h_green] CHAR(2) NOT NULL,
[h_blue] CHAR(2) NOT NULL);
CREATE TABLE [h_entries] (
[_id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[highlight_id] INTEGER NOT NULL,
[bibleID] INTEGER NOT NULL,
[chapterID] INTEGER NOT NULL);
One of the events was on my own device last week (Google was slow on the uptake as the report just arrived today); it was a Samsung Galaxy S2 on 4.0.4. I left a note for myself in the crash report that I had simply rotated the device. Meaning the device had stopped and restarted the app, thus the app went through the process of onDestroy() where I close and dismiss all DataBaseHelper instances via
public static void closeAllInstances() {
for (Object o : sInstances.entrySet()) {
Map.Entry pair = (Map.Entry) o;
((DataBaseHelper) pair.getValue()).close();
Log.d(TAG, pair.getKey() + " closed.");
}
sInstances.clear();
}
and restart.
The app structure is using SlidingMenu with fragments. One fragment for the menu, one for the main view. I call SQLiteDatabase.loadLibs(this)
in the main activity onCreate. I use my DataBaseHelper.getInstance()
prior to executing any DataBaseHelper
method, such as fetchHighlightsByChapter()
. Both the constructor and all methods make a call to openDb().
private String DATABASE_NAME;
private String DATABASE_PATH;
private static HashMap<String, DataBaseHelper> sInstances = new HashMap<>();
private SQLiteDatabase db = null;
private static Context mContext;
private DataBaseHelper(Context context, String dbName) {
super(context, dbName, null, 1);
DATABASE_NAME = dbName;
DATABASE_PATH = mContext.getFilesDir().getPath() + "/databases/" + DATABASE_NAME + ".blb";
openDb();
}
private void openDb() {
if(db != null && db.isOpen()) { return; }
synchronized (BibleReaderActivity.sDataLock) {
try {
String s = "SQLite format 3";
byte[] b = new byte[s.length()];
final int bytesRead = FileUtils.openInputStream(new File(DATABASE_PATH)).read(b);
if(bytesRead == s.length() && s.equals(new String(b))) {
// Unencrypted
db = SQLiteDatabase.openDatabase(DATABASE_PATH, "", null, SQLiteDatabase.OPEN_READWRITE); // Not an encrypted DB
} else {
// Can we open it with the key?
db = SQLiteDatabase.openDatabase(DATABASE_PATH, "abc123", null, SQLiteDatabase.OPEN_READWRITE);
}
} catch (IOException e) {
crashingCallHome("openDb()", e);
System.exit(0);
}
}
}
As you can see, I’m already synchronizing around the SQLiteDatabase.openDatabase()
process. Since SQLLite is supposed to already be thread safe, there isn’t a point to synchronize each query call. Hope this helps. Let me know if there is any more I can do.
Guys, I don’t know how serious you are taking this, or if there is more that I can provide, but I am seeing about 4-5 crashes a day for Caused by: java.lang.IllegalStateException: database not open
when clearly the DB should already be open. It appears that this is happening specifically when the app is reloaded due to device rotation or task switching. I cannot reproduce it at all, but it is happening a lot.
Hi @theBlbDan — we have taken a brief look at this, but have not been unable to reproduce either issue.
That said, we’re wondering if its possible that this might not actually be a problem with SQLCipher, but simply caused by a threading issue. From your sample code, it appears that there is an AsyncTask running query logic. It doesn’t appear, however, that there is anything in place to prevent a race condition where the application gets an instance of the DataBaseHelper that is subsequently closed by the app restart. Consider this scenario:
- Application uses DatabaseHelper.getInstance().
- fetchHighightsByChapter() executes asynchronously and calls openDb().
- openDb() calls isOpen(), which returns true, so the call proceeds and attempts to run a query
- System rotates / restarts, onDestroy() is called, and thus the static DataBaseHelper.closeAllInstances()
- The SQLiteDatabase instance db is closed, but the fetchHiglightsByChapter() call is already running using the db instance directly
- SQLiteDatabase.rawQueryWithFactory() checks the state of the db handle before use internally, finds that it’s closed, and throws an InvalidStateException: database not opened (see https://github.com/sqlcipher/android-database-sqlcipher/blob/master/src/net/sqlcipher/database/SQLiteDatabase.java#L1760)
As far as we are aware, AsyncTasks are not guaranteed to end in a timely manner following onDestroy unless explicitly cancelled by the application.
This same scenario would plausibly explain the original exception you were seeing (library routine called out of sequence). Consider the same flow, but where the db instance is closed by onDestroy after the isOpen() check executes in SQLiteDatabase.rawQueryWithFactory(). In that case, instead of getting a specific InvalidStateExeception thrown by the java wrapper, you’d instead expect a misuse exception, because the closed database handle would be passed to the native sqlite3 functions. SQLITE_MISUSE occurs any time an sqlite3 API call is made using a database handle that has previously been closed by sqlite3_close() — see http://www2.sqlite.org/cvstrac/wiki?p=LibraryRoutineCalledOutOfSequence https://www.sqlite.org/rescode.html#misuse for more information on this.
Thus, it seems at least possible that both issues could be caused by a race condition resulting from the threading model and the way the application handles database connections on restart. Without reports of this issue from other developers, or the ability to reliably reproduce this in a test case, it is really difficult for us proceed further.
The fact that you started to see this after upgrading to 3.5.x is a curious data point, but perhaps not conclusive. Out of curiosity, were there any other application changes that were made in the same release? Have you considered an alternate model for handling database connections, or explicitly cancelling all running AsyncTasks when the activity is destroyed?
@sjlombardo, @developernotes,
Thank you for taking the time to read, research, and respond to this issue. As it likely is for any developer, this was a huge problem for our app due to the large number of customers being affected by it. It does appear that we may have created the problem our selves by misunderstanding an error being provided in LogCat about the databases not being properly closed. It made zero sense, since the error stated that either the database or a cursor was not properly closed.
We ran a full review of cursor access across the project and could not find an unclosed cursor. From this we deduced that it must be complaining that we’re not closing DB’s, so we assumed that we should close them inside the application’s onDestroy(). Obviously, this means every device rotation, which inherently is a lot of open() close(), which is not good. Older, slower devices were going to be severely impacted, but it caused the error to go away.
We allowed ourselves to be seduced by the lack of red in LogCat instead of continuing to research the problem. Based on your previous response about «AsyncTasks are not guaranteed to end in a timely manner … unless explicitly cancelled by the application,» it became obvious that we created the error conditions. We made a gross, noob mistake and I cannot even fathom how we got there, since we should have known better. Somehow, when we created out singleton class, we failed to extend SQLiteOpenHelper, which was the cause for the initial errors.
So, after all of this, I wanted to say thank you for 1) All the work you are doing for the Android community by providing SQLCipher, & 2) your continued patience in providing valuable feedback to the community, even when the problem lies in their court.
Hello @theBlbDan — thanks so much for the kind words, and for letting us know this issue is resolved now!
как изменить путь к базе данных из программы? (при запуске)
Модератор: Модераторы
как изменить путь к базе данных из программы? (при запуске)
Сделал свою первую программу на фри паскале.
Но моя программа запускается только по указанному пути (где лежит проект).
Как сделать так, чтобы программа могла запускаться из любой папки?
ОС Linux Fedora 18 64bit.
я в событие OnShow формы приложения, написал эту строчку:
DataModule1.ZConnection1.Database:=GetCurrentDirUTF8+’/db.sqlite’;
но программа пытается какие то library, хотя проект собран как релиз без отладочной информации и стоит галочка вырезать символы из запускаемого файла (в общем сделано по инструкции на wiki).
Помогите пожалуйста разобраться.
Заранее спасибо.
- midisa
- новенький
- Сообщения: 95
- Зарегистрирован: 13.06.2013 18:27:53
- Откуда: Omsk
-
- Профиль
- Сайт
Re: как изменить путь к базе данных из программы? (при запус
Padre_Mortius » 17.06.2013 20:21:15
В событии создания DataModule прописать
- Код: Выделить всё
ZConnection1.Database:=ExtractFilePath(Application.ExeName)+'db.sqlite';
И DataModule1 поставить первым в списке автосоздаваемых модулей
- Padre_Mortius
- энтузиаст
- Сообщения: 1265
- Зарегистрирован: 29.05.2007 17:38:07
- Откуда: Спб
Re: как изменить путь к базе данных из программы? (при запус
midisa » 17.06.2013 20:28:40
чего то не получается.
добавил строчку в событие бефореконнект, в датамодуле.
procedure TDataModule1.ZConnection1BeforeConnect(Sender: TObject);
begin
ZConnection1.Database:=ExtractFilePath(Application.ExeName)+’db.sqlite’;
end;
переименовал проект и запустил.
Вижу это сообщение об ошибке:
SQL Error: library routine called out of sequence.
Press OK to ignore and risk data corruption.
Press Cancel to kill the program.
Может не туда прописал?
- midisa
- новенький
- Сообщения: 95
- Зарегистрирован: 13.06.2013 18:27:53
- Откуда: Omsk
-
- Профиль
- Сайт
Re: как изменить путь к базе данных из программы? (при запус
svk12 » 17.06.2013 20:54:40
Может быть, так пойдёт:
- Код: Выделить всё
ZConnection1.Database:=ExtractFilePath(Application.ExeName)+PathDelim+'db.sqlite';
- svk12
- постоялец
- Сообщения: 385
- Зарегистрирован: 09.06.2008 18:42:47
Re: как изменить путь к базе данных из программы? (при запус
Padre_Mortius » 17.06.2013 21:11:10
svk12, ExtractFilePath
midisa, пропишите код смены файла БД в DataModule1.DataModuleCreate, а не в BeforeConnection
- Padre_Mortius
- энтузиаст
- Сообщения: 1265
- Зарегистрирован: 29.05.2007 17:38:07
- Откуда: Спб
Re: как изменить путь к базе данных из программы? (при запус
midisa » 18.06.2013 02:41:39
Сделал как Вы сказали. Вот результат (он был и ранее)
———————
SQL Error: library routine called out of sequence.
——————
Он не базу потерял, а что то другое. Если базу переименовать, то сообщение выглядит так:
——————
SQL Error: SQL logic error or missing database.
——————
В моем проекте, только два файла.
1. запускаемый файл.
2. база данных.
Я пробовал удалить все файлы из папки проекта. Как я понял он не может найти самого себя?
Перевел текст в трансляторе:
——————————-
Ошибка SQL: библиотечная процедура называется не по порядку.
——————————
Что это может означать? Есть у кого то мысли?
Добавлено спустя 1 час 19 минут 2 секунды:
Re: как изменить путь к базе данных из программы? (при запуске)
Прописываю жестко путь к базе.
- Код: Выделить всё
ZConnection1.Database:='путь к базе';
Вижу что переменная имеет другое значение, а база как подключалась к той что указано в проекте в настройках так и подключается.
Уважаемые программисты, помогите пожалуйста.
Вы ведь храните настройки подключения к базе в каком то конфигурационном файле….
Где вы его подгружаете и как?
Буду признателен за Вашу помощь.
- midisa
- новенький
- Сообщения: 95
- Зарегистрирован: 13.06.2013 18:27:53
- Откуда: Omsk
-
- Профиль
- Сайт
Re: как изменить путь к базе данных из программы? (при запус
SeZuka » 18.06.2013 07:31:24
Насколько мне помнится Application.ExeName работает только под виндой, под линухом совсем другое используется для определения пути к исполняемому файлу.
Тут почитайте
- SeZuka
- постоялец
- Сообщения: 209
- Зарегистрирован: 05.09.2012 14:58:05
Re: как изменить путь к базе данных из программы? (при запус
Padre_Mortius » 18.06.2013 10:16:14
midisa, выкладывайте ваш проект. У меня приведенный код работает.
SeZuka, Application.Exename отлично работает в линуксе, а в статье пример дан для конфигов.
- Padre_Mortius
- энтузиаст
- Сообщения: 1265
- Зарегистрирован: 29.05.2007 17:38:07
- Откуда: Спб
Re: как изменить путь к базе данных из программы? (при запус
midisa » 18.06.2013 11:38:57
дело не в путях к базе. до базы еще не дошло, а ошибка сообщает что не может найти библиотеки для работы с sql. т.е. если программа линкует библиотеки себе, то программа не может найти саму себя. где то у нее в настройках прописано где брать эти библиотеки. Нужно указать путь к библиекам т.е. к самому запускаемому файлу. А какая это переменная я не знаю.
- midisa
- новенький
- Сообщения: 95
- Зарегистрирован: 13.06.2013 18:27:53
- Откуда: Omsk
-
- Профиль
- Сайт
Re: как изменить путь к базе данных из программы? (при запус
Padre_Mortius » 18.06.2013 12:16:19
midisa, проверяйте настройки компонентов Zeos или выкладывайте проект. Гадать на кофейной гуще дело не благодарное.
- Padre_Mortius
- энтузиаст
- Сообщения: 1265
- Зарегистрирован: 29.05.2007 17:38:07
- Откуда: Спб
Re: как изменить путь к базе данных из программы? (при запус
Vadim » 18.06.2013 12:27:50
midisa
В Вашей ОС установлена библиотека для работы с базой данных SQLite?
- Vadim
- долгожитель
- Сообщения: 4112
- Зарегистрирован: 05.10.2006 08:52:59
- Откуда: Красноярск
Re: как изменить путь к базе данных из программы? (при запус
midisa » 18.06.2013 12:29:58
да конечно
Добавлено спустя 1 минуту 27 секунд:
Re: как изменить путь к базе данных из программы? (при запуске)
система фкдора 18 64 бита, бибоиотека /usr/lib64/libsqlite.so (пишу на память могу ошибится)
Добавлено спустя 1 минуту 10 секунд:
Re: как изменить путь к базе данных из программы? (при запуске)
проект когда откроете, переключите на дебаг версию иначе (в моем случае) релиз почему то не собирается, пока дебаг не собереш.
Добавлено спустя 2 минуты 2 секунды:
Re: как изменить путь к базе данных из программы? (при запуске)
задача сделать так, чтобы программа могла работать с любой папки. если например папку проекта переименовать, то программа отображает сообщение об ошибке.
- midisa
- новенький
- Сообщения: 95
- Зарегистрирован: 13.06.2013 18:27:53
- Откуда: Omsk
-
- Профиль
- Сайт
Re: как изменить путь к базе данных из программы? (при запус
Vadim » 18.06.2013 12:53:32
Код рабочий. Поместил в свою папку, удалил из настроек ZConnection упоминание о БД, т.е. осталось только то, что в процедуре TDataModule1.DataModuleCreate(). База данных прекрасно открывается.
Вам задание: в репозитории Вашей ОС найдите любую программу, которая открывает базы SQLite, установите её у себя и попробуйте ей открыть Вашу базу.
- Vadim
- долгожитель
- Сообщения: 4112
- Зарегистрирован: 05.10.2006 08:52:59
- Откуда: Красноярск
Re: как изменить путь к базе данных из программы? (при запус
midisa » 18.06.2013 12:59:36
спасибо за вашу помощь. вопрос закрыт.
Добавлено спустя 2 минуты 23 секунды:
Re: как изменить путь к базе данных из программы? (при запуске)
мой проект с сервера удален. всем большое спасибо кто помогал в изучении этого и других вопросов.
- midisa
- новенький
- Сообщения: 95
- Зарегистрирован: 13.06.2013 18:27:53
- Откуда: Omsk
-
- Профиль
- Сайт
Вернуться в Lazarus
Кто сейчас на конференции
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 20
Moderators: gto, EgonHugeist
-
dav999
- Fresh Boarder
- Posts: 9
- Joined: 29.08.2008, 07:58
[RESOLVED] Error : SQL Error : library routine called out .
Hello,
i have this error in loading, but this error comming before the oncreate of my first form.
i have verifed my path to the database it’s correct.
i use the last stable realses (6.6.3) and i dev into lazarus/freepascal in ubuntu 8.04.
I have only this error in another computer that haven’t installed FPC/lazarus (i have rename & install the libsqlite.so in /usr/lib)
I have try to install the last svn version, but i have 2 errors when i try to compile it
i have seen this post http://zeos.firmos.at/viewtopic.php?t=1 … d+sequence, but i search the TZSQLiteStatement.Execute routine, i can’t find im.
If anyone have an idea…
Thanks
ps : excuse for my poor english but if anyone speak french
Last edited by dav999 on 03.09.2008, 15:42, edited 1 time in total.
-
ssamayoa
- Junior Boarder
- Posts: 29
- Joined: 14.01.2006, 19:06
Post
by ssamayoa » 29.08.2008, 15:49
Hi.
To which database (MySQL, Oracle, etc.) are you connecting?
Regards.
-
dav999
- Fresh Boarder
- Posts: 9
- Joined: 29.08.2008, 07:58
Post
by dav999 » 29.08.2008, 17:42
Oh excuse me : sqlite3 and i have correctly rename the libsqlite.so in /usr/lib/
-
dav999
- Fresh Boarder
- Posts: 9
- Joined: 29.08.2008, 07:58
Post
by dav999 » 31.08.2008, 21:21
i give an complement information :
in unit ZIBEventAlerter i have this error when i try compiling zeoslib 6.6.3 :
…/Zeoslib/ZEOSDBO-6.6.3-stable/src/component/ZIBEventAlerter.pas(116,23) Error: Duplicate identifier «INFINITE»
Code: Select all
const
IB_MAX_EVENT_BLOCK = 15; // maximum events handled per block by InterBase
IB_MAX_EVENT_LENGTH = 64; // maximum event name length
{$IFDEF LINUX}
INFINITE = $FFFFFFFF;
{$ENDIF}
//error it's the bottom line
{$IFDEF VER140BELOW}
INFINITE = $FFFFFFFF;
{$ENDIF}
threadvar
FStatusVector: TARRAY_ISC_STATUS;
for bypass this error i have comment the bold line i think it’s not the problem ?
-
mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Post
by mdaems » 31.08.2008, 23:30
See bug 131 in our bug tracker. This problem is fixed in SVN 6.6-patches branch.
Mark
-
dav999
- Fresh Boarder
- Posts: 9
- Joined: 29.08.2008, 07:58
Post
by dav999 » 01.09.2008, 22:29
i have check this code, recompiling and reinstall compo but it’s resolve not my problem
-
mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Post
by mdaems » 02.09.2008, 10:55
But the compilation is OK now?
No idea about where to start solving your initial problem, however. Can you check the call stack to see when/where the error is actually raised? More specifically : what zeoslib routine or sqlite dll method is raising the error?
Mark
-
dav999
- Fresh Boarder
- Posts: 9
- Joined: 29.08.2008, 07:58
Post
by dav999 » 02.09.2008, 22:49
yes lazarus compiling without error now
for sql error the problem in the computer i compiled my app i haven’t any error, this error appears only in another computer, i can’t see but i trace my app with this code in form_create :
(«log» is declared textfile in public variables)
Code: Select all
procedure Tfrm_depart.FormCreate%u28Sender%u3a TObject%u29;
begin
//Création du fichier log pour tracer les éventuelles erreurs
assignfile%u28log,ExtractFilePath%u28Application.ExeName%u29 + 'athletes.log'%u29;
rewrite%u28log%u29;
writeln%u28log,'********** ENTREE DANS LA PROCEDURE FORMCREATE ***********'%u29;
and i have not a textfile when i start my app (in another pc if a start in my pc i have no error the app work great), i suppose this error come before the begining of my app ?
Thx
-
mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Post
by mdaems » 02.09.2008, 22:59
Bad sqlite.dll version on the other pc?
Mark
-
dav999
- Fresh Boarder
- Posts: 9
- Joined: 29.08.2008, 07:58
Post
by dav999 » 03.09.2008, 09:08
i work only in linux (ubuntu 8.04) and i use the lastest library (3.6.2) and i rename to libsqlite.so in /usr/lib/
i have tested my app in another pc with unbuntu 7.10 and 8.04 and mandriva 2008
thx
-
dav999
- Fresh Boarder
- Posts: 9
- Joined: 29.08.2008, 07:58
Post
by dav999 » 03.09.2008, 15:45
Ok the problem is resolved a great thanks to mark
in design time a have fill the database path, and this make the error (the database it’s not found in another pc and the error come before the real starting to my app)
Bye
David
-
kabeza
- Fresh Boarder
- Posts: 2
- Joined: 31.03.2010, 13:35
- Location: San Juan, Argentina
- Contact:
SQL Error: library routine called out of sequence
Post
by kabeza » 31.03.2010, 13:43
Hi guys
I made a search and found some threads regarding the error I’ve got while trying to work with SQLite:
SQL Error: library routine called out of sequence
— I downloaded latest ZeosDBO and installed on Delphi7
— Created new project
— Put components, queries, etc.
— Created SQLite DB, tables
— Put sqlite3.dll in project’s folder
— I’ve used Path:=ExtractFilePath(Application.Exename) for loading DB
All went fine on my machine, but moved all the files (project.exe, db.sqlite, sqlite3.dll) to another machine and got
SQL Error: library routine called out of sequence
Can any1 help me to solve this? If I read ok, is this solved in SVN version? should I download svn and recompile everything?
-
mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Post
by mdaems » 03.04.2010, 20:34
No recent changes, so updating SVN will probably not help.
But if your exe runs without trouble on your first PC and outside the IDE you should check on both machines what dll’s and db files are loaded exactly.
According to this post the problem may also be db-filename related.
Mark
-
kabeza
- Fresh Boarder
- Posts: 2
- Joined: 31.03.2010, 13:35
- Location: San Juan, Argentina
- Contact:
Post
by kabeza » 08.04.2010, 19:42
I never thought «playa.sqlite» would be a bad name for my database…
I could not test in the other machine, but I’m beginning to suspect that the fact I have the zConnectionSQL.Connected property = true (at designtime) is making everything go bad when I try to change ZConnectionSQL.Database at mainForm.onCreate
so far, This is the code I have in the mainForm.onCreate
Code: Select all
try
begin
ZConnectionSQL.Disconnect;
Path := ExtractFilePath(Application.exename);
ZConnectionSQL.Database := Path + 'playa.sqlite';
ZConnectionSQL.Connect;
end;
except
MessageDlg('Error!!', mtWarning, [mbOK], 0);
end;
So I’ll update after I run the soft in the other machine
-
mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Post
by mdaems » 14.04.2010, 00:00
Oh, yes. When you connect at startup to a non-existing (development) DB before connecting to the right db this can cause trouble. When changing db at runtime don’t connect in design time.
Mark