You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Claudio Veas <cm...@yahoo.com.ar> on 2005/12/12 01:48:51 UTC

Problems with my first JSP file

Im already on my learning path but I have a problem on my first example and
I dont know exactly what it is. 
This is the JSP File 
 
<HTML>
<HEAD><TITLE>Employee List</TITLE></HEAD>
<BODY>
<%@ page import="java.sql.*" %>
<TABLE BORDER=1 width="75%">
<TR><TH>Last Name</TH><TH>First Name</TH></TR>
<%
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","jonas
,"jonas");
st = conn.createStatement();
rs = st.executeQuery("select * from employees");
while(rs.next()) {
%>
<TR><TD><%= rs.getString("lname_txt") %></TD>
<TD><%= rs.getString("fname_txt") %></TD></TR>
<%
}
%>
</TABLE>
<%
} catch (Exception ex) {
ex.printStackTrace();
%>
<%= ex.getMessage() %>
 
</TABLE>
Ooops, something bad happened:
<%
} finally {
if (rs != null) rs.close();
if (st != null) st.close();
if (conn != null) conn.close();
}
%>
</BODY>
</HTML>
 
and this is the output I get When I try to see it
I have some experience using the JDBC with mysql and i tried to use the ex
getSQLState() function but I got an error.
I really hope you can help me 
Thanks on advance.
Claudio Veas 

Re: Problems with my first JSP file

Posted by Mark Thomas <ma...@apache.org>.
When starting a new thread (ie sending a message to the list about a
new topic) please do not reply to an existing message and change the
subject line. To many of the list archiving services and mail clients
used by list subscribers this  makes your new message appear as part
of the old thread. This makes it harder for other users to find
relevant information when searching the lists.

This is known as thread hijacking and is behaviour that is frowned
upon on this list. Frequent offenders will be removed from the list.
It should also be noted that many list subscribers automatically
ignore any messages that hijack another thread.

The correct procedure is to create a new message with a new subject.
This will start a new thread.

Mark
tomcat-user-owner


Claudio Veas wrote:
> Im already on my learning path but I have a problem on my first example
> and I dont know exactly what it is.
> This is the JSP File
>  
> <HTML>
> <HEAD><TITLE>Employee List</TITLE></HEAD>
> <BODY>
> <%@ page import="java.sql.*" %>
> <TABLE BORDER=1 width="75%">
> <TR><TH>Last Name</TH><TH>First Name</TH></TR>
> <%
> Connection conn = null;
> Statement st = null;
> ResultSet rs = null;
> try {
> Class.forName("com.mysql.jdbc.Driver").newInstance();
> conn =
> DriverManager.getConnection("jdbc:mysql://localhost:3306/test","jonas","jonas");
> st = conn.createStatement();
> rs = st.executeQuery("select * from employees");
> while(rs.next()) {
> %>
> <TR><TD><%= rs.getString("lname_txt") %></TD>
> <TD><%= rs.getString("fname_txt") %></TD></TR>
> <%
> }
> %>
> </TABLE>
> <%
> } catch (Exception ex) {
> ex.printStackTrace();
> %>
> <%= ex.getMessage() %>
>  
> </TABLE>
> Ooops, something bad happened:
> <%
> } finally {
> if (rs != null) rs.close();
> if (st != null) st.close();
> if (conn != null) conn.close();
> }
> %>
> </BODY>
> </HTML>
>  
> and this is the output I get When I try to see it
> I have some experience using the JDBC with mysql and i tried to use the
> ex.getSQLState() function but I got an error.
> I really hope you can help me
> Thanks on advance.
> Claudio Veas 
> 		
> 
> Add FUN to your email - CLICK HERE!
> <http://www.incredimail.com/index.asp?id=96769>
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org