This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes pls help me deal with jsp--oracle database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

pls help me deal with jsp--oracle database connection

amanda wu
Greenhorn

Joined: Mar 16, 2003
Posts: 25
please help me,
my code below connect to an oracle database.
but the code never print out data in database,
but the line"not ok".
i have checked many times, and don't know the reason.
is it due to the code or i put the driver in wrong place?
where should i put the oracle driver then?
i would appreciate your help very much if u can figure it out for me
sincerely
<html><head><title>test db</title></head>
<body>
<%@ page import="java.sql.*"%>
<table border =1 width ="75%">
<tr><th>log_time</th><th>session_id</th><th>message_body</th></tr>
<%
Connection conn=null;
Statement st=null;
ResultSet rs=null;
String dbURL="jdbc racle:thin:@202.79.195.44:1521 btest";
String username="igdnet";
String password="igdnet";
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(dbURL,username,password);
st=conn.createStatement();
rs=st.executeQuery("Select * from T_Session_Logs;");

while(rs.next()){
%>
<tr><td><%=rs.getString("Log_Time")%></td>
<td><%=rs.getString("Session_ID")%></td>
<td><%=rs.getString("Message_Body")%></td></tr>
<%
}
%>
</table>
<%
}
catch (Exception e){
e.printStackTrace();
%>
</table>
not ok:
<%
}finally{
if (rs!=null)rs.close();
if (st!=null)st.close();
if (conn!=null) conn.close();
}
%>
</body></html>
Rajat
Greenhorn

Joined: Mar 20, 2003
Posts: 13
Hi
U can try with
rs=st.executeQuery("Select * from T_Session_Logs");
It may help.
Probably, query should wrong..........
if it does not help then print the exception
out.println(e);
amanda wu
Greenhorn

Joined: Mar 16, 2003
Posts: 25
thank you very much,
finally i made it run
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Hi, seek help and Funny Tell

Welcome to JavaRanch! Please adjust your display names to meet the JavaRanch Naming Policy.
You can change it here.

Thanks!


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pls help me deal with jsp--oracle database connection
 
Similar Threads
javax. servlet. Servlet Exception: java. sql. SQLException
Login Code Error
DB insert using JSP
error showing while retrieving the data from drop down list
Display a list based on JSP input