我将ojdbc7.jar放置在webapp lib文件夹webapp/WEB-INF/lib
中,并尝试在glassfish的tomcat中进行部署。无法找到驱动程序。我正在使用以下代码,该代码遵循jdbc4.0spec对jdbc驱动程序的自动注册:
@WebServlet("/gs")
public class GetEmployeeDetailsServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
try {
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "bms", "abc");
Statement statement = connection.createStatement();
String sql="select * from emp_tbl";
ResultSet resultSet = statement.executeQuery(sql);
while(resultSet.next()){
out.println(resultSet.getInt("eno"));
out.println(resultSet.getString("name"));
out.println(resultSet.getDouble("salary"));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
请给我一个解决方案。