One way to do it would be to make a JSP web service consumable by php. This is a very basic start, but the idea is, you have a jsp which lives on the java server, and it can be called over the web. It takes parameters, then hits the database with those parameters, and returns it. PHP makes a call to this service and reads the data it returns.
DatabaseService.jsp
String query = Request.getParameter('query');
ResultSet rs = MyDbClass.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int colCount = rsmd.getColumnCount();
while (rs.next())
{
for (int i = 1; i <= colCount; i++)
{
String columnName = rsmd.getColumnName(i);
Object value = rs.getObject(i);
out.println(columnName+":"+value.toString()+'\t');
}
out.println("
");
}
oracleConnect.php
$query=urlencode("SELECT * FROM DB.table");
$results=file_get_contents("http://remoteServer.com/DatabaseService.jsp?query=$query");
This is highly simplified, you will need to output the data some way consumable by php like xml, as well as sending other parameters, an api key, using CURL
instead of file_get_contents
, any number of things, but this basic model should get you started in the right direction.