DriverManager connection does NOTHING!
843836Jan 20 2005 — edited Jan 20 2005I am trying to connect to a MYSQL database using a JSP page. I am using the NetBeans IDE. I can (seemingly) connect to the database, but I get nothing from any of my database queries. I do not get any errors, but I do not get any info from the database either. Here is the code for the JSP page. The println statements are so I can track the progress of the program.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.Vector,java.sql.*" %>
<html>
<head><title>JSP Page</title></head>
<body>
<%-- <jsp:useBean id="beanInstanceName" scope="session" class="beanPackage.BeanClassName" /> --%>
<%-- <jsp:getProperty name="beanInstanceName" property="propertyName" /> --%>
<%
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
out.println("Connecting...<br>");
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
out.println("forName...<br>");
while(connection==null){
out.println("Waiting for connection...<br>");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/bob");
}
out.println("Connection found...<br>");
statement = connection.createStatement();
out.println("Statement...<br>");
rs = statement.executeQuery("SELECT * FROM schedule");
out.println("ResultSet...<br>");
while (rs.next()) {
out.println(rs.getString("Encoder_ID")+"<br>");
}
rs.close();
out.println("Closing...<br>");
}
catch(SQLException sqe){}
out.println("Done...<br>");
%>
</body>
</html>
AND HERE IS THE HTML OUTPUT:
Connecting...
forName...
Waiting for connection...
Done...
As you can see, it seems the connection is made, but after that it seems to skip the database query . Any ideas? I cannot figure this out.