B4J Question [SOLVED]error connecting to sqlite using JRDC2

elitevenkat

Active Member
Licensed User
Longtime User
I have attached both jrdc2 server project and client b4j in a zip format.
my client code

Can someone guide me please.

error thrown byjrdc2 server project


WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@27362ef9 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
Mar 15, 2021 9:18:33 AM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@13e3d3dc -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:315)
at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:285)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
Mar 15, 2021 9:18:33 AM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool@27362ef9 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.


B4X:
#Region Project Attributes 
    #MainFormWidth: 600
    #MainFormHeight: 600 
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI 
    Private Button1 As B4XView
    Public cCnn As String ="http://localhost:19180/rdc"
    Public  reqManager As DBRequestManager
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    reqManager.Initialize(Me, cCnn)
    
End Sub

Sub Button1_Click
    
'    xui.MsgboxAsync("Hello World!", "B4X")
'''Dim pool As p
'''    Dim jo As JavaObject = pool
'''    jo.RunMethod("setMaxPoolSize", Array(1))
'''    jo.RunMethod("setMinPoolSize", Array(1))
    LoadPreference
End Sub


Sub LoadPreference
    Dim cmd As DBCommand
 
    cmd.Initialize
    cmd.Name = "select_items"
    
    'cmd.Parameters = Array As Object(Null)
    
    reqManager.ExecuteQuery(cmd, 0, "PREF")

End Sub
 

Attachments

  • tsql.zip
    4.7 KB · Views: 164
  • fajrdc2.zip
    143.9 KB · Views: 148

aeric

Expert
Licensed User
Longtime User
I am not sure where you get the sample code for the client app. Try the project I attached.

There is also an issue with your SQL statement. There is a double quote at the end.
sql.select_items=select * from itemmaster"
 

Attachments

  • Client.zip
    3.9 KB · Views: 181
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
I am not sure where you get the sample code for the client app. Try the project I attached.

There is also an issue with your SQL statement. There is a double quote at the end.
sql.select_items=select * from itemmaster"
Thanks for your reply. I had removed the double quote you had pointed.
my config.prop file settings

B4X:
#DATABASE CONFIGURATION
#SQLite
 
 
JdbcUrl=jdbc:sqlite:epos_slite.db
DriverClass=com.sqlite.JdbcUrl

is the setting correct?

the epos_slite.db is in objects folder of the jrdc project folder.

i am getting the following error. i am running the client project sent by you.
2021-03-15 12:27:40.466:INFO::main: Logging initialized @160ms to org.eclipse.jetty.util.log.StdErrLog
Mar 15, 2021 12:27:40 PM com.mchange.v2.log.MLog
INFO: MLog clients using java 1.4+ standard logging.
Mar 15, 2021 12:27:40 PM com.mchange.v2.c3p0.C3P0Registry
INFO: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2021-03-15 12:27:41.093:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_281-b09
2021-03-15 12:27:41.167:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2021-03-15 12:27:41.167:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2021-03-15 12:27:41.169:INFO:eek:ejs.session:main: node0 Scavenging every 600000ms
2021-03-15 12:27:41.176:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@15d0c81b{/,file:///D:/slitetest/fajrdc2/Objects/www,AVAILABLE}
2021-03-15 12:27:41.181:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened D:\slitetest\fajrdc2\Objects\logs\b4j-2021_03_15.request.log
2021-03-15 12:27:41.203:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@3043fe0e{HTTP/1.1,[http/1.1]}{0.0.0.0:19180}
2021-03-15 12:27:41.204:INFO:eek:ejs.Server:main: Started @900ms
jRDC is running (version = 2.22)
Mar 15, 2021 12:27:45 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1hge0w9agem5zkl3vwiau|1ef7fe8e, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.sqlite.JdbcUrl, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 1hge0w9agem5zkl3vwiau|1ef7fe8e, idleConnectionTestPeriod -> 600, initialPoolSize -> 3, jdbcUrl -> d:/slitetest/t2.db, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize ->...
Mar 15, 2021 12:27:45 PM com.mchange.v2.c3p0.DriverManagerDataSource
WARNING: Could not load driverClass com.sqlite.JdbcUrl
java.lang.ClassNotFoundException: com.sqlite.JdbcUrl
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.mchange.v2.c3p0.DriverManagerDataSource.ensureDriverLoaded(DriverManagerDataSource.java:143)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:173)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
Mar 15, 2021 12:27:45 PM com.mchange.v2.c3p0.DriverManagerDataSource
WARNING: Could not load driverClass com.sqlite.JdbcUrl
java.lang.ClassNotFoundException: com.sqlite.JdbcUrl
 
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
Yes. This is correct. I tested the connection with a sample db inside jRDC2 Objects folder.

Check your additional library folder for sqlite library version.
B4X:
#AdditionalJar: sqlite-jdbc-3.28.0

Thanks again. sqlite-jdbc-3.7.2 is in internal lib folder.
i have downloaded sqlite-jdbc-3.28.0 and it is in internal lib folder.
Hi still same error. i suspect, may be the my sqlite db is corrupt ?
May i request you to test at your end with the attached sqlitedb and jrdc?
 

Attachments

  • epos_slite.zip
    21.8 KB · Views: 156
  • jRDC.zip
    6.3 KB · Views: 187
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
b4j client project error
ResponseError. Reason: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@2cb36eb6 -- timeout at awaitAvailable(), Response: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@2cb36eb6 -- timeout at awaitAvailable()</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre> com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@2cb36eb6 -- timeout at awaitAvailable()</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
ERROR: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@2cb36eb6 -- timeout at awaitAvailable()</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /rdc. Reason:
<pre> com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@2cb36eb6 -- timeout at awaitAvailable()</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
 
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
still error
2021-03-15 14:38:20.058:INFO::main: Logging initialized @159ms to org.eclipse.jetty.util.log.StdErrLog
Mar 15, 2021 2:38:20 PM com.mchange.v2.log.MLog
INFO: MLog clients using java 1.4+ standard logging.
Mar 15, 2021 2:38:20 PM com.mchange.v2.c3p0.C3P0Registry
INFO: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2021-03-15 14:38:20.754:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_281-b09
2021-03-15 14:38:20.807:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2021-03-15 14:38:20.808:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2021-03-15 14:38:20.810:INFO:eek:ejs.session:main: node0 Scavenging every 660000ms
2021-03-15 14:38:20.815:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@646d64ab{/,file:///D:/slitetest/fajrdc2/Objects/www,AVAILABLE}
2021-03-15 14:38:20.819:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened D:\slitetest\fajrdc2\Objects\logs\b4j-2021_03_15.request.log
2021-03-15 14:38:20.836:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@2a742aa2{HTTP/1.1,[http/1.1]}{0.0.0.0:19180}
2021-03-15 14:38:20.836:INFO:eek:ejs.Server:main: Started @940ms
jRDC is running (version = 2.22)
Mar 15, 2021 2:38:26 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1hge0w9agequ0napi2el1|1ef7fe8e, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.sqlite.JDBC, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 1hge0w9agequ0napi2el1|1ef7fe8e, idleConnectionTestPeriod -> 600, initialPoolSize -> 3, jdbcUrl -> jdbc:sqlite:epos_slite.db, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSiz...
(TimeoutException) com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@2cb36eb6 -- timeout at awaitAvailable()
Command: , took: 20086ms, client=192.168.0.9
Mar 15, 2021 2:39:00 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@548afe74 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unsupported file format)
at org.sqlite.core.DB.newSQLException(DB.java:940)
at org.sqlite.core.DB.newSQLException(DB.java:953)
at org.sqlite.core.DB.throwex(DB.java:918)
at org.sqlite.core.NativeDB.prepare_utf8(Native Method)
at org.sqlite.core.NativeDB.prepare(NativeDB.java:134)
at org.sqlite.core.DB.prepare(DB.java:257)
at org.sqlite.jdbc3.JDBC3Statement.execute(JDBC3Statement.java:52)
at org.sqlite.SQLiteConfig.apply(SQLiteConfig.java:142)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:65)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:28)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:21)
at org.sqlite.JDBC.createConnection(JDBC.java:115)
at org.sqlite.JDBC.connect(JDBC.java:90)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
 
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
You cannot use pooling with SQLite. That's why I created a modified JRDC2 server: https://www.b4x.com/android/forum/threads/modded-jrdc2-w-sqlite-support-and-more.85578/
Thanks for the link.

Can u provide me the client side code please ?

i get the following error in jrdc log

2021-03-15 21:30:59.332:INFO::main: Logging initialized @157ms to org.eclipse.jetty.util.log.StdErrLog
Fetching IP address via getLocalHostLANAddress
2021-03-15 21:30:59.870:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_281-b09
2021-03-15 21:30:59.940:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2021-03-15 21:30:59.940:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2021-03-15 21:30:59.942:INFO:eek:ejs.session:main: node0 Scavenging every 660000ms
2021-03-15 21:30:59.949:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@4678c730{/,file:///D:/testslite/jRDCv2_mod.2020.05.28.01a/Objects/www,AVAILABLE}
2021-03-15 21:30:59.952:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened D:\testslite\jRDCv2_mod.2020.05.28.01a\Objects\logs\b4j-2021_03_15.request.log
2021-03-15 21:31:00.162:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@3bfdc050{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
2021-03-15 21:31:00.163:INFO:eek:ejs.Server:main: Started @992ms
Modified jRDC is running (version = 2.22)
Note: jRDC is running without V1 support
Bound to: 192.168.0.9:17178
(ClassNotFoundException) java.lang.ClassNotFoundException: b4j.example.dbrequestmanager$_dbcommand
Command: , took: 22ms, client=127.0.0.1
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

OliverA

Expert
Licensed User
Longtime User
b4j.example.dbrequestmanager$_dbcommand
Make sure you define the DBResult and DBRequest types in the main module of your client (always)
 
Upvote 0
Top