Old 31-08-2007, 13:05   #1 (permalink)
brendan hart
Invincisible
 
brendan hart's Avatar
 
Join Date: May 2007
Posts: 221
Send a message via MSN to brendan hart
Errors with anyprogramming

Ok so ive been programming in jsp and whenever running sql commands you have to run a try statement and a catch for when there is an error.
the catch does catch(exception e){ out.println(e.getMessage()); } thats all(i think) and i can enter anything I like, say there are no comments instead of having an sql message should i change it to say there is no comments or would there be a different way of doing this?

Code:
try{ Class.forName("org.apache.derby.jdbc.ClientDriver"); //load bridge driver con = DriverManager.getConnection("jdbc:derby://localhost:1527/cms","admin","******"); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT * FROM \"ADMIN\".\"Content\" ORDER BY \"ADMIN\".\"Content\".\"PostID\" DESC"); while(rs.next()){ out.print("<h1>" + rs.getString("Title") + "</h1><p>" + rs.getString("Body") + "</p>" + "<span class='floatleft'>Posted By: " + rs.getString("PostBy") + "</span><span class='floatright'>Date: " + rs.getString("Date") + "</span>"); } } catch(Exception e) {out.print(e.getMessage()); }

dont mind the code its dirty ill fix it later
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8