Many providers offer web space with MySQL and PHP support but without the possibility to access these databases directly from a client running a Java application.
This driver transforms JDBC API calls into HTTP requests to a set of PHP scripts running on a web server thus providing transparent access from Java to all databases accessible from PHP on the web server.
The following sample lines of code illustrate the usage of the driver:
import java.sql.*;
...
Class driverClass = class.forName("com.satline.jdbc.http.Jdbc2HttpDriver");
Driver driver = (Driver) driverClass.newInstance();
Properties info = new Properties();
info.setProperty("user", "mysqluser");
info.setProperty("password", "nobodyknowsit");
info.setProperty("proxy.host", "proxy");
info.setProperty("proxy.port", "3128");
Connection conn = driver.connect("jdbc:jdbc2http:db.satline.com/shopdb@http://www.satline.com/jdbc2http/mysql",
info);
Statement stm = conn.createStatement();
ResultSet rs = stm.executeQuery("SELECT first_name, birthday FROM person");
while (rs.next()) {
System.out.println("first name: " + rs.getString("first_name)" +
", birthday: " + rs.getDate("birthday"));
}
rs.close();
stm.close();
stm = conn.createStatement();
stm.executeUpdate("UPDATE person SET birthday = '1920.05.30'\n" +
"WHERE first_name = 'Guenter'");
stm.close();
conn.close();