Código PHP:
import java.sql.*;
class base {
public static void main(String args[]) {
String first="SELECT * FROM prod";
Statement orden = null;
Connection con = null;
ResultSet rs = null;
ResultSetMetaData rsm = null;
int i=1,j=1;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception err) {
System.out.println("ERROR: " + err);
}
try {
con= DriverManager.getConnection("jdbc:mysql://localhost/base", "lobbyroom", "123456789");
}
catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
try {
orden = con.createStatement();
rs = orden.executeQuery(first);
rsm = rs.getMetaData();
while (rs.next()) {
while (i<=rsm.getColumnCount()) {
try {
System.out.println(rs.getString(i));
i++;
} catch (Exception err1) {
System.out.println("Acabado: " + err1);
}
}
}
}
catch (SQLException exa) {
System.out.println("ERROR: " + exa);
}
try {
con.close();
} catch (Exception errata) {
System.out.println(errata);
}
}
}