pls help me deal with jsp--oracle database connection
amanda wu
Greenhorn
Joined: Mar 16, 2003
Posts: 25
posted
0
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
posted
0
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
posted
0
thank you very much, finally i made it run
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
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