Hi,
> I am running the PHP/Java Bridge in Tomcat. Is there any
> way for PHP to call a native JDBC Type 4 driver (available
> as a jar file) directly through the PHP/Java Bridge?
Yes, provided that your WEB-INF/lib directory contains the jdbc driver .jar file and its dependencies.
> Do you have an example of this?
I think someone has posted an example on this mailing list: (=> http://sourceforge.net/mailarchive/forum.php?thread_name=753185.95697.qm%40web30906.mail.mud.yahoo.com&forum_name=php-java-bridge-users )
---------- mysqlTest.php ----------------
<?php require_once("http://localhost:8080/JavaBridge/java/Java.inc");
# load driver from java.ext.dirs using Class.forName(...)
new java("com.mysql.jdbc.Driver");
$conn = java("java.sql.DriverManager")->getConnection("jdbc:mysql://localhost/test", "root", "");
$st = $conn->createStatement ();
$st->executeUpdate ("drop table hugo");
$st->executeUpdate ("create table hugo (i int primary key, v varchar(255))");
$st->executeUpdate ("insert into hugo (i, v) values (1, 'first')");
$st->executeUpdate ("insert into hugo (i, v) values (2, 'second')");
$st->execute("select * from hugo");
$rs = $st->getResultSet ();
while ((string)$rs->next ()) {
echo $rs->getInt("i"); echo ", ";
echo $rs->getString("v"); echo "\n";
}
$rs->close();
$st->close();
$conn->close ();
?>
---------------------------------------------------------
# test
php -d allow_url_include=On mysqlTest.php
=>
1, first
2, second
Regards,
Jost Boekemeier
|