Código PHP:
package javabeans;
import java.sql.*;
import java.util.Vector;
public class DataBaseSelect {
private Vector result;
public DataBaseSelect() {
result = new Vector();
} // constructor DataBaseSelect
public String connect() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
return "Driver Loaded!";
} catch (Exception E) {
return "Unable to load driver.";
}
}
public String select() {
try {
Connection C = DriverManager.getConnection("jdbc:odbc:raul");
Statement Stmt = C.createStatement();
ResultSet myResult = Stmt.executeQuery("SELECT * From personas");
while (myResult.next()) {
result.addElement(myResult.getString(1));
}
// Clean up
myResult.close();
Stmt.close();
C.close();
return "Connection Success!";
} catch (SQLException E) {
return "SQLException: " + E.getMessage();
}
}
/**
* Accessor for result
**/
public Vector getResult() {
return result;
}
/**
* Mutator for result
**/
public void setResult(Vector avector) {
result = avector;
}
} // class DataBaseSelect