Hi. I tried oracle database connection within JSP but got class not found exception. I put the oracle jdbc driver "classes111.zip" in the WEB-INF/lib, still got the same error. My codes as following, thanks in advance for any help/ideas. <%@ page import="java.sql.*" %> <%@ page import="db.cashTypeBean" %> <jsp:useBean id="cashType" class="db.cashTypeBean"> <% Connection connection = null; Statement statement = null; ResultSet results = null; try{ System.out.println("before loading driver..."); Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("complete loading driver..."); String url = "jdbc racle:thin@hercules.fmd.cargill.com:1521:test"; String s = "IDV"; String query = "SELECT * FROM RDC.CSH_TYPS WHERE CSH_TYP_CD=" +s; connection = DriverManager.getConnection(url, "dev_rdc", "dev_rdc"); statement = connection.createStatement(); results = statement.executeQuery(query); if (results.next()){ cType.setCode(results.getString("CSH_TYP_CD")); cType.setName(results.getString("LKUP_NM")); } connection.close(); } catch (ClassNotFoundException e){ System.out.println("Fail to load database driver!"); } finally{ try{ if(connection!=null) connection.close();} catch (SQLException e) {} } %>
triveni sangam
Greenhorn
Joined: Jan 12, 2001
Posts: 11
posted
0
Check ur classpath...it seems that ur application is not getting the required classes.
hong zhang
Ranch Hand
Joined: Jun 07, 2001
Posts: 30
posted
0
Triveni, Thank you for your quick response. I'm using tomcat 4.0 beta 5. I updated classpath in the startup bat file, and the oracle driver loaded. In connection statement, I got an error: javax.servlet.ServletException:Sub Protocol must be specific in connection URL. Don't know what it look for. Any advice? Thank you in advance! Hong
Originally posted by triveni sangam: Check ur classpath...it seems that ur application is not getting the required classes.
hong zhang
Ranch Hand
Joined: Jun 07, 2001
Posts: 30
posted
0
I missed a ":" in specifying the database connection. Thanks for your help, Triveni. Hong
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.