B4J Question JDRC2 Timeout (Can't find a database?)

Cliff McKibbin

Member
Licensed User
I have set up JDRC2 with a B4XPages program 'TestJDRC' to try and get it going on my own PC per Erel's video tutorial. In the tutorial, he already had a database on his pc which he connected to. I have not created a database on the pc.

As you can see from the B4J log, JDRC2 is starting and appears to have accepted my first 'command' from the B4A program to create a table so I know the connection is working. The JDRC2 program is crashing on some kind of timeout which at this point I think is that it can't find a database.

The documentation booklet 'B4XSqlliteDatabaseV1' does show a B4J example of initializing/creating a sqllite database but the JDRC2 program does not have an 'init' in it.

I was, therefore, hoping that if the DB doesn't exist, the JDRC2 handler would create it as the sql1.initialize does in b4a, but that may not be the case.

The following questions/answers would help me to get going:
1. I would like to confirm that the timeout is probably caused by the lack of a DB. If not, perhaps there is another problem.

2. I would like to confirm that JDRC2 will not create a 'mysql' DB?

3. Should I be able to create a DB on the pc by using the standard b4j construct as discussed in the sqllite booklet (page 8):

B4J Add the line below in Main module
#Region Project Attributes. #AdditionalJar: sqlite-jdbc-3.7.2
And: SQL1.InitializeSQLite(DBDirName, DBFileName, True)
DBDirName = Directory name of the database.
DBFileName = Database file name.
True = Create if necessary False don't create the database. SQL1.InitializeSQLite(DBDirName, DBFileName, True) In B4J, SQL1.Initialize is used to initialize SQL drivers.
To use SQLite, you must initialize it with SQL1.InitializeSQLite

The problem with both of these is that the config file appears to be using 'mysql', which I presume is not 'sqllite'.

4. If not, how is the best way to create a DB on my PC that is compatible with JDRC2 and 'mysql'. I looked and I appear to have downloaded 'MySql' onto my PC at some point, but don't have a utility (that I see) to actually create a DB.

5. Once I create it, where do I put it? The Config entry directory is 'localHost'. I don't know where that is on a pc.

I appreciate any help to bring my ignorance of this linkage to the databases up a notch.

Thanks, Cliff McKibbin


I have included the logs of both programs, the 'config.properties', and the two zip files.

Log of JDRC2
--note the comment line 'Method-Batch2' is my proof that JDRC2 received my CreateTable request.
Waiting for debugger to connect...
Program started.
2022-05-17 14:04:47.631:INFO::main: Logging initialized @1978ms to org.eclipse.jetty.util.log.StdErrLog
May 17, 2022 2:04:48 PM com.mchange.v2.log.MLog
INFO: MLog clients using java 1.4+ standard logging.
May 17, 2022 2:04:52 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]
2022-05-17 14:04:54.657:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 1.8.0_192-b12
2022-05-17 14:04:55.211:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2022-05-17 14:04:55.211:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2022-05-17 14:04:55.217:INFO:eek:ejs.session:main: node0 Scavenging every 600000ms
2022-05-17 14:04:55.245:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@153b3e6{/,file:///C:/B4J/jRDC/Objects/www,AVAILABLE}
2022-05-17 14:04:55.320:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\B4J\jRDC\Objects\logs\b4j-2022_05_17.request.log
2022-05-17 14:04:55.567:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@27f723{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
2022-05-17 14:04:55.568:INFO:eek:ejs.Server:main: Started @9920ms
Emulated network latency: 100ms
jRDC is running (version = 2.23)
method: batch2
May 17, 2022 2:07:29 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 -> 2rvxwhao1mlk3hv64rcnq|1f2a7d5, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.cj.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 2rvxwhao1mlk3hv64rcnq|1f2a7d5, idleConnectionTestPeriod -> 600, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost/SyncDB?characterEncoding=utf8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTime...
(TimeoutException) com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@154b04f -- timeout at awaitAvailable()
Command: , took: 20263ms, client=10.0.0.175
May 17, 2022 2:11:40 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@4e1eb4 -- 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:

Log of TestJDRC
Logger connected to: samsung SAMSUNG-SM-J727AZ
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
*** mainpage: B4XPage_Created
Create Table Issued
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@154b04f -- 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@154b04f -- 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@154b04f -- timeout at awaitAvailable()</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.z-SNAPSHOT</a><hr/>
</body>
</html>
** Activity (main) Pause event (activity is not paused). **
*** mainpage: B4XPage_Disappear [mainpage]


Config.Properties
Note-there was an initial warning in the JDRC2 program that said the driver: com.mysql.jdbc.driver was deprecated and to use this version with the 'cj' in it. This eliminated the message in the log.

#Lines starting with '#' are comments.
#Backslash character at the end of line means that the command continues in the next line.

#DATABASE CONFIGURATION
DriverClass=com.mysql.cj.jdbc.Driver
JdbcUrl=jdbc:mysql://localhost/SyncDB?characterEncoding=utf8
User=root
Password=
#Java server port
ServerPort=17178

#example of MS SQL Server configuration:
#DriverClass=net.sourceforge.jtds.jdbc.Driver
#JdbcUrl=jdbc:jtds:sqlserver://<server address>/<database>

#example of postegres configuration:
#JdbcUrl=jdbc:postgresql://localhost/test
#DriverClass=org.postgresql.Driver

#SQL COMMANDS
sql.CreateTable=CREATE TABLE IF NOT EXISTS FSSync (\
SysName CHAR(2) NOT NULL,\
Id CHAR(20) NOT NULL,\
IdFrom CHAR(2) NOT NULL,\
IdTo CHAR(2) NOT NULL,\
sData CHAR(30) )

sql.AddSync=INSERT INTO FSSync VALUES (?,?,?,?,?)
sql.ReadSync=SELECT * FROM FSSync WHERE SysName= ? and Id=? and IdTo=?
 

Attachments

  • jRDC.zip
    4.4 KB · Views: 17
  • TestJDRC.zip
    12.8 KB · Views: 20
Top