Hi,
If it were me, I would use some kind of data access layer written in
java. So the java data access layer would deal with the JNDI and
database statements, and php would just call it.
$userdao = new Java("com.foo.dao.UserDAO");
$userdao->addUser("dan","moore");
The UserDAO class would have an addUser method that would do all the
database manipulations.
I know that is not exactly what you are asking, but that is the way I'd
do this.
You might be able to return a jdbc connection across the php java bridge
as well. Have a java class get the connection from JNDI, and then run
normal JDBC commands against that connection.
$connmanager = new Java("com.foo.manager.ConnectionManager");
$stmt = $connmanager->createStatement("select * from users");
... more jdbc
I don't know if it is possible to get what is essentially a JDBC
connection from JNDI and treat it as a php db connection (which is what
the code you have below does).
Dan
On 1/20/2009 4:12 AM, php...@li... wrote:
> Hi there,
>
> I have deployed the JavaBridge war file into my Tomcat backend.
>
> I have successfully connected JSP to MySQL using MySQL Connector / J using JNDI (which is configured in the Tomcat server.xml and web.xml files).
>
> How can I use the PHP-Java Bridge to connect PHP to MySQL using the JNDI connection?
>
> I have tried this PHP code to call the JNDI connection jdbc/TestDB:
> <?php
>
> require_once("java/Java.inc");
>
> $dbh = mysql_connect("java:comp/env/jdbc/TestDB")
>
> ?>
>
> But i receive the error:
>
> Warning - mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Unknown MySQL server host 'java' (1)
>
> Is what I am trying to achieve possible with the PHP-Java Bridge? Do I need to require more than the java/Java.inc file in my code?
>
> If you could you supply me with or point me to the correct code to achieve this connection I would be most grateful.
>
> Kind regards
>
>
> This message has been scanned for viruses by MailControl - www.mailcontrol.com
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> php-java-bridge-users mailing list
> php...@li...
> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users
|