Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Problem while trying to run a jdbc using servlet on jboss
Problem while trying to run a jdbc using servlet on jboss [message #1114710] Mon, 23 September 2013 05:22 Go to next message
Lavanya M is currently offline Lavanya MFriend
Messages: 1
Registered: September 2013
Junior Member
I wrote a servlet program to access data from my database. When run as a simple jdbc application, its working well...but when trying to run on jboss...its being an issue!! Can anyone please help me with this??? Thank you!!

Here's my code and follows is the console i am getting:

package com.vacation.mypackage;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

* Servlet implementation class SampleServlet
public class SampleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

* @see HttpServlet#HttpServlet()
public SampleServlet() {
// TODO Auto-generated constructor stub
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Connection conn = null;
Statement stmt = null;

// Set response content type
PrintWriter out = response.getWriter();
String title = "Database Result";
String docType =
"<!doctype html public \"-//w3c//dtd html 4.0 " +
out.println(docType +
"<html>\n" + "<head><title>" + title + "</title></head>\n" +
"<body bgcolor=\"#f0f0f0\">\n" +
"<h1 align=\"center\">" + title + "</h1>\n");

out.println("hi before Class.forName");

conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Emp","root","1234");

stmt = conn.createStatement();
String qry;
qry = "SELECT emp_id, fname, dept_id, work_location_id FROM Employee";
ResultSet rs = stmt.executeQuery(qry);

int emp_id = rs.getInt("emp_id");
String fname = rs.getString("fname");
int dept_id = rs.getInt("dept_id");
int work_location_id = rs.getInt("work_location_id");

out.println("Employee ID: " + emp_id + "<br/>");
out.println("First Name: " + fname + "<br/>");
out.println("Department ID: " + dept_id + "<br/>");
out.println("Work Location ID:" + work_location_id + "<br/>");

out.println("THE END");

}catch(SQLException se){
}catch(Exception e){
}catch(SQLException se2){
}catch(SQLException se){

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub


10:40:49,263 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/VacationTrackingSystem
10:40:50,276 ERROR [STDERR] java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from BaseClassLoader@1671cbc{vfs:///D:/Lavanya/.metadata/.plugins/}

10:40:50,276 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(

10:40:50,276 ERROR [STDERR] at java.lang.ClassLoader.loadClass(

10:40:50,276 ERROR [STDERR] at java.lang.ClassLoader.loadClassInternal(

10:40:50,276 ERROR [STDERR] at java.lang.Class.forName0(Native Method)

10:40:50,276 ERROR [STDERR] at java.lang.Class.forName(

10:40:50,276 ERROR [STDERR] at com.vacation.mypackage.SampleServlet.doGet(

10:40:50,323 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(

10:40:50,323 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(

10:40:50,323 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

10:40:50,323 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(

10:40:50,338 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(

10:40:50,338 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(

10:40:50,338 ERROR [STDERR] at

10:40:50,338 ERROR [STDERR] at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(

10:40:50,338 ERROR [STDERR] at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(

10:40:50,338 ERROR [STDERR] at

10:40:50,338 ERROR [STDERR] at

10:40:50,338 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(

10:40:50,338 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(

10:40:50,338 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(

10:40:50,338 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(

10:40:50,338 ERROR [STDERR] at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(

10:40:50,338 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(

10:40:50,338 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(

10:40:50,338 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

10:40:50,338 ERROR [STDERR] at$

10:40:50,338 ERROR [STDERR] at

An early answer is really appreciated..thanks!!
Re: Problem while trying to run a jdbc using servlet on jboss [message #1114930 is a reply to message #1114710] Mon, 23 September 2013 12:26 Go to previous message
Kunal Ghosh is currently offline Kunal GhoshFriend
Messages: 5
Registered: August 2013
Junior Member
Please check you have added the mysql jar file.
Previous Topic:[Galileo Java] Can't create new class
Next Topic:lowResourcesConnections attribut doesn't work with jetty8.1.11
Goto Forum:

Current Time: Sun Mar 07 21:12:30 GMT 2021

Powered by FUDForum. Page generated in 0.03157 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top