Connection String in PHP using JDBC

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
rajani
Forum Newbie
Posts: 3
Joined: Fri Feb 27, 2009 4:41 am

Connection String in PHP using JDBC

Post by rajani »

Hi Everybody,

Can we connect any database in php using JDBC. If Yes then please let me know woh we can connect it or if not then what is the reason behind it.

With Regards
Rajani Gupta
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Connection String in PHP using JDBC

Post by jayshields »

JDBC is an API for Java to connect to databases. Why would you need to use JDBC in PHP?
rajani
Forum Newbie
Posts: 3
Joined: Fri Feb 27, 2009 4:41 am

Re: Connection String in PHP using JDBC

Post by rajani »

i need to know only that how can we connect oracle using php? JDBC connectivity is possible in php or not.
rajani
Forum Newbie
Posts: 3
Joined: Fri Feb 27, 2009 4:41 am

Re: Connection String in PHP using JDBC

Post by rajani »

We are using server which is supporting only JDBC connections.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Connection String in PHP using JDBC

Post by jayshields »

Your Oracle server only accepts JDBC connections? Well, in that case, you're going to have trouble connecting to it using PHP.

If not, PHP has extensions for working with Oracle. This search told me that.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Connection String in PHP using JDBC

Post by Chris Corbyn »

If you're looking for PHP's JDBC equivalent, it's PDO.

http://php.net/pdo
Nisha3102
Forum Newbie
Posts: 5
Joined: Tue Mar 24, 2009 5:41 pm

Re: Connection String in PHP using JDBC

Post by Nisha3102 »

Hi Rajani..
I am stuck with the same pbm. I want to know how can I get jdbc connection in php. If you have got the solution plz reply
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Connection String in PHP using JDBC

Post by jayshields »

Theoretically you could actually do it, but it'll be much better for you if you just reconfigure the database to not only accept JDBC connections.
Nisha3102
Forum Newbie
Posts: 5
Joined: Tue Mar 24, 2009 5:41 pm

Re: Connection String in PHP using JDBC

Post by Nisha3102 »

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

Code: Select all

 
        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. Actually I need the connection object to send as a parameter to Jasper report FillManagerClass.
Last edited by Benjamin on Thu May 14, 2009 4:31 pm, edited 2 times in total.
Reason: Added [code=java] tags.
Post Reply