Jump to content

PHP and jdbc -urgent help


Nisha3102

Recommended Posts

I am trying to integrate php and jasper reports. I have to generate a report from db and for that I need a jdbc connection object in php. Could any one please help me on this. I have referred some links on google .They all mention the same process of creating an instance of a java class and then calling a getConnection() method of that class.

 

Following the getCOnnection() method

 

    public Connection getConnection()

{

Connection conn = null;

try {

//Change these settings according to your local configuration

Class.forName(this.getDriver());

conn = DriverManager.getConnection(

this.getConnectString(),

this.getUser(),

this.getPassword());

//return conn;

}catch(ClassNotFoundException e){

e.printStackTrace();

}catch(SQLException e){

e.printStackTrace();

}

return conn;

}

 

But when I call this method from php it doesnt return me anything . Could anyone please help me. I need jdbc connection object coz I need to send this as the parameter to FillManager class of Jasper Reports.

Link to comment
https://forums.phpfreaks.com/topic/158184-php-and-jdbc-urgent-help/
Share on other sites

I am trying to integrate php and jasper reports. I have to generate a report from db and for that I need a jdbc connection object in php. Could any one please help me on this. I have referred some links on google .They all mention the same process of creating an instance of a java class in PHP and then calling a getConnection() method of that class.

PHP code -

$jdbcalt = new Java("jdbcalt");

$jdbcalt->getConnection()

 

Java Code in Jdbcalt class

Following is the getCOnnection() method

 

    public Connection getConnection()

{

Connection conn = null;

try {

//Change these settings according to your local configuration

Class.forName(this.getDriver());

conn = DriverManager.getConnection(

this.getConnectString(),

this.getUser(),

this.getPassword());

//return conn;

}catch(ClassNotFoundException e){

e.printStackTrace();

}catch(SQLException e){

e.printStackTrace();

}

return conn;

}

 

But when I call this method from php it doesnt return me anything . Could anyone please help me. I need jdbc connection object coz I need to send this as the parameter to FillManager class of Jasper Reports.

Oh I missed your Java bit. I thought you did via command line "php getConnections()" :D. You should post your stuff. I don't know what kind of an object is Connection, but give it a toString method and have getConnection write out conn with System.out.println(conn); That should use the toString() method printout.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.