aeric Expert Licensed User Longtime User Sep 24, 2021 #1 The pool is responsible for maintaining the connections. An alternative for a connections pool is a process global SQL variable. However for it to work properly all the handlers should be single threaded handlers. Click to expand... Referring to the tutorial '[Server] Building web servers with B4J' https://www.b4x.com/android/forum/threads/server-building-web-servers-with-b4j.37172/ I am now confused with this statement. No problem to use connection pool for MySQL and set the SingleThreaded to False by default. B4X: srvr.AddHandler("/hello", "HelloPage", False) But then now if I use SQLite for the backend, should I set SingleThreaded as True? Last edited: Sep 24, 2021
The pool is responsible for maintaining the connections. An alternative for a connections pool is a process global SQL variable. However for it to work properly all the handlers should be single threaded handlers. Click to expand... Referring to the tutorial '[Server] Building web servers with B4J' https://www.b4x.com/android/forum/threads/server-building-web-servers-with-b4j.37172/ I am now confused with this statement. No problem to use connection pool for MySQL and set the SingleThreaded to False by default. B4X: srvr.AddHandler("/hello", "HelloPage", False) But then now if I use SQLite for the backend, should I set SingleThreaded as True?
EnriqueGonzalez Expert Licensed User Longtime User Sep 24, 2021 #2 Hi aeric, the single thread is only for the server handler it has nothing to do with the database, the driver and the pooler are in charge of managing that info, Upvote 0
Hi aeric, the single thread is only for the server handler it has nothing to do with the database, the driver and the pooler are in charge of managing that info,
OliverA Expert Licensed User Longtime User Sep 26, 2021 #3 aeric said: But then now if I use SQLite for the backend, should I set SingleThreaded as True? Click to expand... No. Just don't use pooling with SQLite. For SQLite, use the InitializeSQLite method to retrieve your SQL object. Use this single object for all your DB requests. @Erel has provided the code to ensure that only one NonQuery statement will be executed at any given time. This is how I do it in my modified jRDC2 server. Note: you also need to enable WAL mode Sources: WAL mode: Thread '[WebApp] Concurrent access to SQLite databases' https://www.b4x.com/android/forum/threads/webapp-concurrent-access-to-sqlite-databases.39904/ B4J's SQL: https://github.com/AnywhereSoftware...SQL/src/anywheresoftware/b4j/objects/SQL.java My jRDC2 mod: https://www.b4x.com/android/forum/threads/modded-jrdc2-w-sqlite-support-and-more.85578/ Upvote 1
aeric said: But then now if I use SQLite for the backend, should I set SingleThreaded as True? Click to expand... No. Just don't use pooling with SQLite. For SQLite, use the InitializeSQLite method to retrieve your SQL object. Use this single object for all your DB requests. @Erel has provided the code to ensure that only one NonQuery statement will be executed at any given time. This is how I do it in my modified jRDC2 server. Note: you also need to enable WAL mode Sources: WAL mode: Thread '[WebApp] Concurrent access to SQLite databases' https://www.b4x.com/android/forum/threads/webapp-concurrent-access-to-sqlite-databases.39904/ B4J's SQL: https://github.com/AnywhereSoftware...SQL/src/anywheresoftware/b4j/objects/SQL.java My jRDC2 mod: https://www.b4x.com/android/forum/threads/modded-jrdc2-w-sqlite-support-and-more.85578/
aeric Expert Licensed User Longtime User Sep 26, 2021 #4 OliverA said: No. Just don't use pooling with SQLite. For SQLite, use the InitializeSQLite method to retrieve your SQL object. Use this single object for all your DB requests. @Erel has provided the code to ensure that only one NonQuery statement will be executed at any given time. This is how I do it in my modified jRDC2 server. Note: you also need to enable WAL mode Sources: WAL mode: Thread '[WebApp] Concurrent access to SQLite databases' https://www.b4x.com/android/forum/threads/webapp-concurrent-access-to-sqlite-databases.39904/ B4J's SQL: https://github.com/AnywhereSoftware...SQL/src/anywheresoftware/b4j/objects/SQL.java My jRDC2 mod: https://www.b4x.com/android/forum/threads/modded-jrdc2-w-sqlite-support-and-more.85578/ Click to expand... So the short answer is No. I understand about pooling, just confused after I read the tutorial again. Upvote 0
OliverA said: No. Just don't use pooling with SQLite. For SQLite, use the InitializeSQLite method to retrieve your SQL object. Use this single object for all your DB requests. @Erel has provided the code to ensure that only one NonQuery statement will be executed at any given time. This is how I do it in my modified jRDC2 server. Note: you also need to enable WAL mode Sources: WAL mode: Thread '[WebApp] Concurrent access to SQLite databases' https://www.b4x.com/android/forum/threads/webapp-concurrent-access-to-sqlite-databases.39904/ B4J's SQL: https://github.com/AnywhereSoftware...SQL/src/anywheresoftware/b4j/objects/SQL.java My jRDC2 mod: https://www.b4x.com/android/forum/threads/modded-jrdc2-w-sqlite-support-and-more.85578/ Click to expand... So the short answer is No. I understand about pooling, just confused after I read the tutorial again.
Jmu5667 Well-Known Member Licensed User Longtime User Sep 26, 2021 #5 aeric said: So the short answer is No. I understand about pooling, just confused after I read the tutorial again. Click to expand... On server apps always set SingleThreaded to false as it refers to the threading method uses on the handler. Setting it to true means that the handler code will run on the main thread. There maybe use cases where it is set to true but I have not encountered this so far. Upvote 0
aeric said: So the short answer is No. I understand about pooling, just confused after I read the tutorial again. Click to expand... On server apps always set SingleThreaded to false as it refers to the threading method uses on the handler. Setting it to true means that the handler code will run on the main thread. There maybe use cases where it is set to true but I have not encountered this so far.