Coder Social home page Coder Social logo

php-jdbc-bridge's Introduction

PHP-JDBC Bridge

The PHP-JDBC bridge is a service and library for allowing a PHP application to interface with a database for which only a JDBC driver exists. This is a fork of PJBS.

The java component runs as a service which accepts socket requests from the PHP component allowing the transfer of request and response between PHP and the JDBC database.

Requirements

  • Java 1.6+
  • PHP 5.3+
  • A JDBC driver

Build (Java Service)

To build the PHP-JDBC bridge jar:

cd java
./build.sh

To build a PHP-JDBC RPM:

cd java
./build.sh
./build-rpm.sh

Usage

Java Service

To run the service:

java -cp 'lib/pjbridge.jar:lib/commons-daemon-1.0.15.jar:lib/<JDBC driver>.jar Server <JDBC driver entry point> <port>

Example:

cd java
java -cp 'lib/pjbridge.jar:lib/commons-daemon-1.0.15.jar:lib/dharma.jar' Server dharma.jdbc.DharmaDriver 4444

where the lib directory contains the php-jdbc jar, the commons-daemon jar and your JDBC driver jar.

PHP

Example:

<?php
require "PJBridge.php";

$dbHost = "server";
$dbName = "";
$dbPort = "1990";
$dbUser = "dharma";
$dbPass = "";

$connStr = "jdbc:dharma:T:${dbHost}:${dbName}:${dbPort}";

$db = new PJBridge();
$result = $db->connect($connStr, $dbUser, $dbPass);
if(!$result){
    die("Failed to connect");
}

$cursor = $db->exec("SELECT * FROM \"AR Customer File\"");

while($row = $db->fetch_array($cursor)){
    print_r($row);
}

$db->free_result($cursor);

php-jdbc-bridge's People

Contributors

iancr01 avatar jcotton1123 avatar loorschot avatar sryoung0721 avatar stevewinter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

php-jdbc-bridge's Issues

Why set up this project?

Hi guys,
I am now using php to connect SAP HANA and found that there is no official driver for PHP but for JAVA it has. So it seems your project is suit for me. But I still search for any other way except this. So I want to know why you set up this project? Do you also have the same problem?

Thanks a lot in advance.

error: could not load JDBC driver

Hi.
I try run your app

java -cp 'lib/pjbridge.jar:lib/commons-daemon-1.2.2.jar:lib/dharma.jar' Server dharma.jdbc.DharmaDriver 4444

but i have this error

error: could not load JDBC driver

And this file lib/dharma.jar dosn't exists.

How can I load JDBC driver?
Thanks.

query timeout?

Hi,

First of all, cheers, such a helpful tool!

I was wondering how to use php to set timeout to a query, ie the php-bridge equivalent of -

Statement stmt = connection.prepareStatement("SELECT * FROM xxx");
stmt.setQueryTimeout(10);
 
//This would throw an SQLTimeoutException if it exceeds 10 seconds
ResultSet result = stmt.executeQuery();

Alternatively, is there an option to cancel a statement, php access to Statement.cancel() ?

Thanks,
Eli

Missing LICENSE file

Hi,

first of all, thanks for taking the time to maintain this project.

I am currently considering using this in one of my projects, however I need to know if this is released under a compatible license.

As this was forked from an LGPL 2.0 project, am I correct in assuming that this is also LGPL 2.0? Could you please add a LICENSE file to clarify?

Thanks!

Do you want to make a release version?

Hello, I don't know much about the logic of Java. Do you want to make a release version? Combined with the documents, it's easier for novices to write on the road. Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.