Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DriverManager connection does NOTHING!

843836Jan 20 2005 — edited Jan 20 2005
I 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2005
Added on Jan 20 2005
1 comment
46 views