The database is locally I understand that it is placed the libraries are already placed from jdbc and the jar of mysql but does not pull the data
You have three very important mistakes:
try/catch
is to show the stacktrace
to know where an exception occurs and why it happens. jdbc:mysql
Your try/catch
does nothing or shows nothing if you catch a Exception
..
Try changing the connection url of
jdbc:mysql//localhost/db?etc...
a
jdbc:mysql://localhost/db?etc...
Normally the port should also be specified:
jdbc:mysql://localhost:3306/db?etc...
If this does not solve your error, (and even if you solve it!) add:
e.printStackTrace();
At your catch(Exception e){ .... aca ...}
If you leave the url uncorrected you will get a
java.sql.SQLException: No suitable driver found for jdbc: mysql // localhost / etc ...
Important not to leave spaces in the url, otherwise you will also get this exception
If you leave the spaces in forName("[espacio]com.mysql.jdbc.Driver")
the following exception will be thrown:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Your final code should be something like this:
<%
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(" jdbc:mysql://localhost/cursosjsp?user=root");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from usuarios");
while (rs.next()) {
// etc ...
}
} catch (Exception e) {
e.printStackTrace();
}
%>