This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

pls help me deal with jsp--oracle database connection

 
amanda wu
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
thank you very much,
finally i made it run
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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!
 
I agree. Here's the link: http://aspose.com/file-tools
    Bookmark Topic Watch Topic
  • New Topic