0

m trying to connect my project wid oracle db ..wts wrong wid dis code yr....:(

<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@ page import ="java.io.*"%>
<%@ page import ="javax.servlet.*"%>
<%@ page import ="javax.servlet.http.*"%>
<%@ page import ="java.sql.*"%>
<%@ page import="java.sql.*" %>
<html>
    <head>
        <title>db</title>
    </head>
    <body>
    <% try{
        System.out.println("hi");
     Class.forName("oracle.jdbc.OracleDriver");

Connection con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE","system", "system");
Statement s=con.createStatement();
System.out.println("hi");
ResultSet rs = s.executeQuery("select * from demo");
while(rs.next())
       {%>
    <p> <%rs.getInt(1);%></p>
    <p> <% rs.getString(2);%> </p>
    <%}
 }
    catch(Exception e){
    out.println("Unable to connect to database.");
    System.out.println(e.getMessage());}
 %>
    </body>
    </html>

this is making me crazy..

Edited by Ezzaral: Code formatting

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by stultuske
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.