php5 and java code problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

php5 and java code problem

Post by thomas777neo »

Here is the code:

Code: Select all

$host = 'localhost';
$db = 'ampbase';
$user = 'thomas';
$pwd = 'thomas';

Java("com.mysql.jdbc.Driver"); // init
$conn = Java("java.sql.DriverManager")->getConnection("jdbc:mysql://$host/$db", $user, $pwd);
$stmt = $conn->createStatement();
$rs = $stmt->executeQuery("SELECT * FROM username");

while($rs->next()) 
{
	printf("On %s article %s\n", $rs->getString("description"));
} //while($rs->next())
Here is the error:
Fatal error: Call to undefined function Java()

What now???
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Do a phpinfo() and see if Java extension lib is loaded/included.

____________
For phpinfo, in an empty file type this and run...

Code: Select all

<?php phpinfo() ?>
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

It is enabled
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Code: Select all

Java("com.mysql.jdbc.Driver"); // init
$conn = Java("java.sql.DriverManager")->getConnection("jdbc:mysql://$host/$db", $user, $pwd);
you forgot new

Code: Select all

new Java("com.mysql.jdbc.Driver"); // init
$conn = new Java("java.sql.DriverManager")->getConnection("jdbc:mysql://$host/$db", $user, $pwd);
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

here are my php.ini java settings:

Code: Select all

extension=php_java.dll

&#1111;Java]
java.class.path = C:\xampp\php\extensions\php_java.jar
java.home = C:\Program Files\Java\jdk1.5.0\bin
java.library = C:\Program Files\Java\jdk1.5.0\jre\bin\client\jvm.dll
java.library.path = C:\xampp\php\extensions
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

Oops

Now it crashes my apache server???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

is there a reason you are connecting to the local mysql server, but not using the mysql extensions php already provides? .. or is this just experimenting?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Yea why u trying to connect like that ?

I would understand when trying to use some java class doing whatever but connecting to the DB like that is kinda URmmm..

Code: Select all

$callJava = new Java('javaFunction', "{$whatever param}");
$answer = $callJava->yourJavaClass();
Now that would make sence :)
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

I'm just experimenting.

I don't mind what I do in java. As long as I can just get it to work without it crashing my apache server
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

Anything Else
Post Reply