java.sql.SQLException: Before start of result set
Posted by: Evan Weeks
Date: February 25, 2005 08:42AM

Database has a table named "ships", with only one row of data entered. Here's the code:

public String displayTest()
{
String output = "";
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(Exception e)
{
output += e.toString()+"<br><hr><br>";
}

try
{

Connection conn = DriverManager.getConnection("jdbc:mysql://143.158.194.130:3306/EVE Shipwright?user=root&password=wolf77");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM ships;");
output += "<b>"+rs.getString("Name")+"</b>";
output += "<br><br>";
output += rs.getString("Description");
output += "<br><br>";

}
catch(SQLException e)
{
output += e.getMessage()+"<br><hr><br>";
output += e.toString();
}

return output;

}

Here's the JSP:

<%@ page import="EVESW.jdbc.*"%>
<html>
<body>
<%
dbTest cls = new dbTest();
%>
<%=cls.displayTest() %>
</body>
</html>


I saw a bug in the bug databse here on this site about this error. Is there a known workaround for this, or am I SOL on using the column names to pull data from the ResultSet?

Options: ReplyQuote


Subject
Written By
Posted
java.sql.SQLException: Before start of result set
February 25, 2005 08:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.