Page 1 of 1
php5 and java code problem
Posted: Thu Mar 31, 2005 6:29 am
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???
Posted: Thu Mar 31, 2005 6:52 am
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...
Posted: Thu Mar 31, 2005 7:11 am
by thomas777neo
It is enabled
Posted: Thu Mar 31, 2005 7:19 am
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);
Posted: Thu Mar 31, 2005 7:20 am
by thomas777neo
here are my php.ini java settings:
Code: Select all
extension=php_java.dll
ї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
Posted: Thu Mar 31, 2005 7:29 am
by thomas777neo
Oops
Now it crashes my apache server???
Posted: Thu Mar 31, 2005 12:25 pm
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?
Posted: Thu Mar 31, 2005 11:54 pm
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

Posted: Fri Apr 01, 2005 1:26 am
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
Posted: Mon Apr 04, 2005 2:20 am
by thomas777neo
Anything Else