Hi all...

I have to make a query on a DB, and I made this code:

=============

<html>
<body>

<p>gui 1</p>

<%@ page import =
"java.io.*,java.util.*,java.net.*,java.sql.*,javax.servlet.*,javax.servlet.http.*"%>

<%!

String url = "jdbc:odbc:teste";
Connection con;
Statement stmt;


public void jspInit()
{
        System.out.print("starting conection");
        //super.init(servletConfig);
        try
        {
           Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           con = DriverManager.getConnection(url,"","");
           stmt = con.createStatement();
        }
        catch(SQLException sql)
        {
          System.out.println("init error");
        }
        catch(ClassNotFoundException fnf)
        {
          System.out.println("init error");
        }
        System.out.println("ready!");
}
public void jspDestroy()
{
        System.out.print("closing conection");
        try
        {
        stmt.close();
        con.close();
        }
        catch(SQLException sql)
        {
          System.out.println("init error");
        }
        System.out.println("ready!");
}
%>

<p>gui3</p>

<%
String pesquisa = "select * from pessoa where nome = 'gui2'";
stmt.executeQuery(pesquisa);
%>

<p>fim</p>

</body>
</html>

==================

On Control Panel I set my database as "teste" (the bridge). I have some
data on the table "pessoa"  to make the query also..

Well....  the code is okay. But I don`t know how to print the result of
this query on the screen.... in the JSP file...

Can anybody help me???

Thank you,
Guilherme


Reply via email to