H2 and PHP

1,536 views
Skip to first unread message

jjari

unread,
Feb 25, 2009, 12:18:02 PM2/25/09
to H2 Database
Hi
Can we connect PHP ti H2 DB ?

thx
jjari

Johann Schleier-Smith

unread,
Feb 25, 2009, 3:12:12 PM2/25/09
to h2-da...@googlegroups.com
PHP does not include support for JDBC connections, so this isn't straightforward, but if you do want to use PHP with a JDBC data source there are a few different approaches that you could try:

* ODBC to JDBC bridge - I'm not aware of free solutions, but commercial products include: http://www.easysoft.com/products/data_access/odbc_jdbc_gateway/ and http://www.datadirect.com/products/jdbc/index.ssp.  You can then use the ODBC support that comes with PHP to connect to the H2 database.
* Use a PHP to Java bridge - this will allow you to invoke Java code from within PHP, so you can use the Java JDBC client provided with H2.  Free software is available at http://php-java-bridge.sourceforge.net/pjb/.  Zend Server also supports this capability, see: http://www.zend.com/en/products/server/
* Use the Quercus implementation of PHP - this is a pure Java implementation of PHP that allows you to integrate JDBC data sources easily.

I haven't actually implemented PHP + H2, so these are just suggestions, rather than proven approaches.  I think you can make any of the above work, though it will likely take some effort to figure all the details out.

               - Johann

Joshua Paine

unread,
Feb 25, 2009, 3:25:30 PM2/25/09
to h2-da...@googlegroups.com
H2 can pretend to be postgres, so I think you should be able to just
point PHP's PDO at H2 with a postgres-style DSN.

--
Joshua Paine
LetterBlock: Web applications built with joy
http://letterblock.com/
301-576-1920

Thomas Mueller

unread,
Feb 26, 2009, 1:19:28 PM2/26/09
to h2-da...@googlegroups.com
Hi,

> H2 can pretend to be postgres, so I think you should be able to just
> point PHP's PDO at H2 with a postgres-style DSN.

In theory this should work. However I have never tested it so far. I
guess there could be some problems because H2 doesn't fully support
the PostgreSQL syntax yet.

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages