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
thomas777neo
Forum Contributor
Posts: 214 Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa
Post
by thomas777neo » Thu Mar 31, 2005 6:29 am
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???
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Thu Mar 31, 2005 6:52 am
Do a
phpinfo() and see if Java extension lib is loaded/included.
____________
For phpinfo, in an empty file type this and run...
thomas777neo
Forum Contributor
Posts: 214 Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa
Post
by thomas777neo » Thu Mar 31, 2005 7:11 am
It is enabled
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Thu Mar 31, 2005 7:19 am
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);
thomas777neo
Forum Contributor
Posts: 214 Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa
Post
by thomas777neo » Thu Mar 31, 2005 7:20 am
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
thomas777neo
Forum Contributor
Posts: 214 Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa
Post
by thomas777neo » Thu Mar 31, 2005 7:29 am
Oops
Now it crashes my apache server???
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Mar 31, 2005 12:25 pm
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?
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Thu Mar 31, 2005 11:54 pm
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
thomas777neo
Forum Contributor
Posts: 214 Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa
Post
by thomas777neo » Fri Apr 01, 2005 1:26 am
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
thomas777neo
Forum Contributor
Posts: 214 Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa
Post
by thomas777neo » Mon Apr 04, 2005 2:20 am
Anything Else