Hi,
Your code seems OK, except that Class.forName() throws
ClassNotFoundException, which is not a SQLException, try to catch this too.-
( take a look the corrected code below)
Walter Jerusalinsky
Buenos Aires, Argentina
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Luc Saint-Elie
> Sent: Sunday, April 18, 1999 2:26 PM
> To: [EMAIL PROTECTED]
> Subject: [BEGINNER] Very basic JSP-JDBC use
>
>
> Hello,
>
> I'm trying to learn JSP (with GNUJSP), I've no real problems
> using servlets but
> I don't really understand where put stuff in a JSP file.
>
> This very basic JDBC (ODBC:JDBC) code fails because it doesn't
> "throws' the
> exception.. but i don't know where put the "throws"
>
> Thanks in advance
> -------
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <%@ import="java.io.*,java.sql.*,javax.servlet.*,javax.servlet.http.*" %>
>
> </head>
> <body bgcolor="#FFFFFF">
> <%
> Connection con = null;
> Statement stmt = null;
> ResultSet rs = null;
> ResultSetMetaData md = null;
>
> try {
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> con =
> DriverManager.getConnection("jdbc:odbc:BIC","","");
> stmt= con.createStatement();
> stmt = con.createStatement();
> rs = stmt.executeQuery("SELECT * FROM Articles_News");
> md = rs.getMetaData();
> out.println("<H1>Liste des news</H1>");
> while (rs.next()) {
> out.println("<BR>");
> for (int i = 1; i <
> md.getColumnCount(); i++) {
> out.print(rs.getString(i) + ",
> ");
> }
> }
> stmt.close();
> rs.close();
> }
> catch (SQLException e) {
> e.printStackTrace(out);
> }
catch (ClassNotFoundException e) { //HERE
> e.printStackTrace(out);
> }
>
> %>
> </body>
> </html>
>
> ----------------
>
>
> +------------------------------------------------+
> | Luc Saint-Elie |
> | 53, rue Caulaincourt |
> | 75018 Paris France |
> | Tel: 01 42 52 09 62 / 06 12 90 19 65 |
> | email : [EMAIL PROTECTED] |
> +------------------------------------------------+
> | Servlet Taverne a site devoted to servlets |
> | ..and Java server side technologies |
> | ATTENTION NEW URL !!! |
> | url : http://www.interpasnet.com/JSS |
> +------------------------------------------------+
>
> ==================================================================
> =========
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff JSP-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".