|Anonymous | Login | Signup for a new account||03-28-2020 07:54 PDT|
|Main | My View | View Issues | Change Log | Docs|
|Viewing Issue Simple Details [ Jump to Notes ]||[ View Advanced ] [ Issue History ] [ Print ]|
|ID||Category||Severity||Reproducibility||Date Submitted||Last Update|
|0001859||[Quercus]||minor||always||07-09-07 18:37||08-01-07 08:46|
|Summary||0001859: JSR223: mysql_connect: Can't find database for driver|
Using Quercus (SVN trunk, the product version drop-down has no SVN branches) as a JSR-223 ScriptEngine.
-------------- PHP -------------
mysql_connect("host", "username", "password");
----------- EOF PHP -------------
com.caucho.quercus.QuercusModuleException: Can't find database for driver 'com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource' and url 'jdbc:mysql://localhost:3306/' [^] [mysql_select_db]
I went in with a debugger using the SVN trunk as reference. This is what I found out.
As the connection requires the name of the database but PHP mysql interface insists on two calls (connect and select_db) then on eval'ing the first line the database name is missing and eval'ing the mysql_select_db the host, username, password are missing.
In a container this is resolved by the QuercusServlet calling setDatabase on the Quercus object. Quercus object's database name is used in the lookup.
In standalone environment there is no servlet and hence incomplete connection string. The current workaround seems to be using QuercusScriptEngine explicitly (not the ScriptEngine interface) and calling setDatabase on the Quercus object.
The solution would be to provide a way of connecting to a database in two steps. First gather the information with mysql_connect and init the connection after mysql_select_db.
Or maybe I'm missing something here :)
|Attached Files||patch.txt [^] (4,077 bytes) 07-10-07 15:55|
I've been working on it a bit more. I've modified to source to get my things working and based on that I propose a solution.
Probably the requirements are:
* Not to break PHP interfaces (mysql_connect, mysql_select_db)
* From JSR223 point of view retain encapsulation (no manual injection through getting an instance of Quercus and providing the datasource)
Why not have mysql_connect accept a JDBC string optionally as the host part?
* It is easily detectable from the string
* Won't have to save state to worry about mysql_select_db
* Will provide somewhat confusion (people accidently not benefitting from acquiring a connection through the Context lookup in the container)
Will look like this:
mysql_connect("jdbc:mysql://host/db?user=user&password=pwd", [^] "user", "pwd");
I've attached a patch to explain my idea. I've also made getQuercus in QuercusScriptEngine.java public to provide workarounds.
Thanks for the comments. Database should work now with JSR 223 and other app servers.
|07-09-07 18:37||toomasr||New Issue|
|07-09-07 18:38||toomasr||Issue Monitored: toomasr|
|07-10-07 15:55||toomasr||File Added: patch.txt|
|07-10-07 15:55||toomasr||Note Added: 0002107|
|08-01-07 07:05||nam||Status||new => assigned|
|08-01-07 07:05||nam||Assigned To||=> nam|
|08-01-07 08:46||nam||Status||assigned => closed|
|08-01-07 08:46||nam||Note Added: 0002170|
|08-01-07 08:46||nam||Resolution||open => fixed|
|08-01-07 08:46||nam||Fixed in Version||=> 3.1.3|
|02-14-08 01:08||taho||Issue Monitored: taho|
| Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
35 total queries executed.|
28 unique queries executed.