troubleshooting Question

database connection

Avatar of Raftor
Raftor asked on
Java
16 Comments1 Solution309 ViewsLast Modified:
Hi Experts,

I am having trouble connecting to a mysql database.  For simplicity i have two files 1) dbconnect.jsp and 2) display_results.jsp.  


--------------dbconnect.jsp------------------
<%
      String inServer = "irpclanadmin1";
      String inDBName = "leave";
      String DATABASE_URL = "odbc:mysql://" + inServer + ":3306/" + inDBName;      
      Class.forName("com.mysql.odbc.Driver").newInstance();
      Connection con = DriverManager.getConnection(DATABASE_URL, "username","pass");
%>

-------------display_results.jsp
<%@ page language ="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ include file="dbconnect.jsp" %>
<%            
      Statement stmt = con.createStatement();
      
      ResultSet check = stmt.executeQuery("SELECT userSName FROM userdetails");
      String userName = "";
      
      while(check.next())
      {
            userName = check.getString(1);
            out.print(userName);
      }
%>

The problem is i am getting this displayed when i open display_results.jsp
javax.servlet.ServletException: com.mysql.odbc.Driver
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
at org.apache.jsp.display_0005fresults$jsp._jspService(display_0005fresults$jsp.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)

...
...
Any help would be greatly appreciated
Raftor....
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 16 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros