我正在尝试使用hibernate读取数据库的记录,我的代码在控制台应用程序上工作正常。但是,当我为servlet尝试相同的代码时,它给出了以下错误,我正在使用Tomcat。 我已经在Eclipse中包含了odbc6.jar文件。我使用的是Oracle11g。
itemName
我的配置文件看起来像这样
HTTP Status 500 - Cannot open connection
type Exception report
message Cannot open connection
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.hibernate.exception.JDBCConnectionException: Cannot open connection
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700)
org.hibernate.loader.Loader.doQuery(Loader.java:801)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
org.hibernate.loader.Loader.loadEntity(Loader.java:2037)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3294)
org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
com.hibernate.dao.BookDAOImpl.read(BookDAOImpl.java:27)
com.servlet.SelectServlet.doGet(SelectServlet.java:36)
javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Root cause
ava.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:xe
java.sql.DriverManager.getConnection(DriverManager.java:596)
java.sql.DriverManager.getConnection(DriverManager.java:187)
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1700)
org.hibernate.loader.Loader.doQuery(Loader.java:801)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
org.hibernate.loader.Loader.loadEntity(Loader.java:2037)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3294)
org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
com.hiberate.dao.BookDAOImpl.read(BookDAOImpl.java:27)
com.servlet.SelectServlet.doGet(SelectServlet.java:36)
javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52