Как подконнектиться к базе

Bill_G
Дата: 29.05.2006 16:17:01
Написал сервлет
________________________________________________________________

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;
import java.sql.*;

public class JDBCQueryServlet extends HttpServlet {

Connection conn = null;

public void init()
throws ServletException {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521","scott","tiger");
} catch (SQLException e) {
conn = null;
throw new ServletException(e.getMessage());
}
}


public void destroy() {
try {
if (conn!= null) conn.close();
} catch (SQLException ignore) {}
}


public void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

PrintWriter out= response.getWriter();

response.setContentType("text/html");

out.println("<HTML>");
out.println("<HEAD> <TITLE> The JDBCQueryServlet"+
"</TITLE> </HEAD>");
out.println("<BODY>");
String condition = request.getParameter("cond");
if (condition != null) {
out.println("<H3> Search results for <I>" + condition + " </I> </H3><B>");

doQuery(condition, out);

out.println(" </B> <HR><BR>");
}



printForm(out);

out.close();
}
_________________________________________________________

Надо личто либо настраивать в Oracle чтобы заработало