|
From: <php...@li...> - 2009-02-04 04:17:16
|
One of the uses I currently have for Php-Java Bridge is to allow PHP to connect to mySQL. Doing this in Windows is simple, all I have to do is add the following in the php.ini file:
[PHP_MySQL]
extension=php_mysql.dll
And then copy-paste the php_mysql.dll from the dll's that come with the php installer into (apache-tomcat installation directory)/webapps/JavaBridge/Web.INF/cgi.
What I want to know is if it is an equivalent way of doing this in Red Hat Linux. For instance, instead of say php_mysql.dll, is there a php_mysql.so file out there somewhere?
Thank you in advance for your assistance
-Kevin
|
|
From: <php...@li...> - 2009-02-04 10:52:20
|
1. Download mysql-connector-java.jar
2. Copy mysql-connector-java.jar to your java.ext.dirs (usually "/usr/java/default/lib/ext")
# (or start a simple Java VM using /usr/share/java as java.ext.dirs)
java -Djava.ext.dirs=/usr/share/java -jar ~/JavaBridge.jar SERVLET:8080 3 "" &
3. Use the driver as usual:
---------- 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
|
|
From: <php...@li...> - 2009-02-06 09:01:40
|
Tried doing the steps, and it results into this: [root@medgrid ext]# java -Djava.ext.dirs=/usr/share/java -jar ~/php-java-bridge/JAVA.STANDALONE/JavaBridge.jar SERVLET:8080 3 "" & [1] 8710 [root@medgrid ext]# Feb 06 16:59:37 VMBridge INFO : VM : 1.5.0_07@http://java.sun.com/ Feb 06 16:59:37 VMBridge INFO : VMBridge version : 5.4.3.1 Feb 06 16:59:37 VMBridge INFO : logFile : Feb 06 16:59:37 VMBridge INFO : default logLevel : 3 Feb 06 16:59:37 VMBridge INFO : socket : SERVLET:8080 Feb 06 16:59:37 VMBridge INFO : java.ext.dirs : /usr/share/java Feb 06 16:59:37 VMBridge INFO : php.java.bridge.base: /root Feb 06 16:59:37 VMBridge INFO : thread pool size : 20 Feb 06 16:59:37 VMBridge INFO : JavaBridgeRunner started on port INET:8080 java.lang.RuntimeException: java.net.BindException: Address already in use at php.java.bridge.Standalone.init(Standalone.java:214) at php.java.bridge.Standalone.main(Standalone.java:313) Caused by: java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at java.net.ServerSocket.<init>(ServerSocket.java:141) at php.java.bridge.TCPServerSocket.newServerSocket(TCPServerSocket.java:60) at php.java.bridge.TCPServerSocket.<init>(TCPServerSocket.java:79) at php.java.bridge.TCPServerSocket.create(TCPServerSocket.java:51) at php.java.bridge.Standalone.bind(Standalone.java:75) at php.java.bridge.JavaBridge.bind(JavaBridge.java:235) at php.java.bridge.JavaBridgeRunner.bind(JavaBridgeRunner.java:159) at php.java.bridge.http.HttpServer.<init>(HttpServer.java:92) at php.java.bridge.JavaBridgeRunner.<init>(JavaBridgeRunner.java:78) at php.java.bridge.JavaBridgeRunner.getRequiredStandaloneInstance(JavaBridgeRunner.java:134) at php.java.bridge.JavaBridgeRunner.main(JavaBridgeRunner.java:559) at php.java.bridge.Standalone.checkServlet(Standalone.java:237) at php.java.bridge.Standalone.init(Standalone.java:200) ... 1 more In other words, it stops there, and I have to Ctrl+C to type commands again. Is this normal? ________________________________ From: "php...@li..." <php...@li...> To: php...@li... Sent: Wednesday, February 4, 2009 6:52:14 PM Subject: Re: [Php-java-bridge-users] Need Help for Linux: Connecting Php and MySQL using Php-Java Bridge 1. Download mysql-connector-java.jar 2. Copy mysql-connector-java.jar to your java.ext.dirs (usually "/usr/java/default/lib/ext") # (or start a simple Java VM using /usr/share/java as java.ext.dirs) java -Djava.ext.dirs=/usr/share/java -jar ~/JavaBridge.jar SERVLET:8080 3 "" & 3. Use the driver as usual: ---------- 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 ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
|
From: <php...@li...> - 2009-02-06 12:10:37
|
Hi,
[port 8080]
> Caused by: java.net.BindException: Address already in use
if you have a J2EE server running on port 8080, you don't need to start another one.
Regards,
Jost Bökemeier
|
|
From: <php...@li...> - 2009-02-06 09:13:34
|
Nevermind, i forgot to turn tomcat-apache off. However, I think to messed up with Php-Java Bridge, as I now can't access the code (and the php-java-bridge page) I used to see if I got the desired results or not. Any way to undo the damage. ________________________________ From: "php...@li..." <php...@li...> To: php...@li... Sent: Friday, February 6, 2009 5:01:36 PM Subject: Re: [Php-java-bridge-users] Need Help for Linux: Connecting Php and MySQL using Php-Java Bridge Tried doing the steps, and it results into this: [root@medgrid ext]# java -Djava.ext.dirs=/usr/share/java -jar ~/php-java-bridge/JAVA.STANDALONE/JavaBridge.jar SERVLET:8080 3 "" & [1] 8710 [root@medgrid ext]# Feb 06 16:59:37 VMBridge INFO : VM : 1.5.0_07@http://java.sun.com/ Feb 06 16:59:37 VMBridge INFO : VMBridge version : 5.4.3.1 Feb 06 16:59:37 VMBridge INFO : logFile : Feb 06 16:59:37 VMBridge INFO : default logLevel : 3 Feb 06 16:59:37 VMBridge INFO : socket : SERVLET:8080 Feb 06 16:59:37 VMBridge INFO : java.ext.dirs : /usr/share/java Feb 06 16:59:37 VMBridge INFO : php.java.bridge.base: /root Feb 06 16:59:37 VMBridge INFO : thread pool size : 20 Feb 06 16:59:37 VMBridge INFO : JavaBridgeRunner started on port INET:8080 java.lang.RuntimeException: java.net.BindException: Address already in use at php.java.bridge.Standalone.init(Standalone.java:214) at php.java.bridge.Standalone.main(Standalone.java:313) Caused by: java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at java.net.ServerSocket.<init>(ServerSocket.java:141) at php.java.bridge.TCPServerSocket.newServerSocket(TCPServerSocket.java:60) at php.java.bridge.TCPServerSocket.<init>(TCPServerSocket.java:79) at php.java.bridge.TCPServerSocket.create(TCPServerSocket.java:51) at php.java.bridge.Standalone.bind(Standalone.java:75) at php.java.bridge.JavaBridge.bind(JavaBridge.java:235) at php.java.bridge.JavaBridgeRunner.bind(JavaBridgeRunner.java:159) at php.java.bridge.http.HttpServer.<init>(HttpServer.java:92) at php.java.bridge.JavaBridgeRunner.<init>(JavaBridgeRunner.java:78) at php.java.bridge.JavaBridgeRunner.getRequiredStandaloneInstance(JavaBridgeRunner.java:134) at php.java.bridge.JavaBridgeRunner.main(JavaBridgeRunner.java:559) at php.java.bridge.Standalone.checkServlet(Standalone.java:237) at php.java.bridge.Standalone.init(Standalone.java:200) ... 1 more In other words, it stops there, and I have to Ctrl+C to type commands again. Is this normal? ________________________________ From: "php...@li..." <php...@li...> To: php...@li... Sent: Wednesday, February 4, 2009 6:52:14 PM Subject: Re: [Php-java-bridge-users] Need Help for Linux: Connecting Php and MySQL using Php-Java Bridge 1. Download mysql-connector-java.jar 2. Copy mysql-connector-java.jar to your java.ext.dirs (usually "/usr/java/default/lib/ext") # (or start a simple Java VM using /usr/share/java as java.ext.dirs) java -Djava.ext.dirs=/usr/share/java -jar ~/JavaBridge.jar SERVLET:8080 3 "" & 3. Use the driver as usual: ---------- 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 ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ php-java-bridge-users mailing list php...@li... https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
|
From: <php...@li...> - 2009-02-06 12:06:15
|
Hi,
> Nevermind, i forgot to turn tomcat-apache off.
why do you want to switch tomcat off?
> However, I think to messed up with Php-Java Bridge, as I
> now can't access the code (and the php-java-bridge page)
> I used to see if I got the desired results or not. Any way
> to undo the damage.
Which damage? Just start tomcat again and your PHP/Java code will work again.
Regards,
Jost Bökemeier
|
|
From: <php...@li...> - 2009-02-04 21:03:42
|
Hi,
why don't you simply require a functional PHP environment? The bridge can be configured to use the system PHP installation instead of the local PHP binary within WEB-INF/cgi/.
> [PHP_MySQL]
> extension=php_mysql.dll
>
> And then copy-paste the php_mysql.dll from the dll's
I don't think this will work. The php mysql.so (php_mysql.dll) have been compiled against a specific PHP version and a specific mysql version:
[jostb@carlos ~]$ locate mysql.so
/usr/lib/php/modules/mysql.so
/usr/lib/php/modules/pdo_mysql.so
[jostb@carlos ~]$ ldd /usr/lib/php/modules/mysql.so
/usr/lib/php/modules/mysql.so:
linux-gate.so.1 => (0x00110000)
libmysqlclient.so.15 => /usr/lib/mysql/libmysqlclient.so.15 (0x0011d000)
The php_mysql driver depends on the version # of the mysql client library (version 15) in this case. A different client library might cause a crash.
I don't think it makes sense to ship a complete mysql installation with each PHP application. However, there are several open-source pure Java-based relational databases which can be easily packaged with your PHP/Java web application.
Regards,
Jost Boekemeier
|