Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MySqlConnection {
- private static Connection conn;
- public static Connection getConn() {
- try {
- Context initContext = new InitialContext() ;
- Context envContext = (Context)initContext.lookup("java:/comp/env") ;
- DataSource ds = (DataSource) envContext.lookup("jdbc/joinmyparty") ;
- conn = ds.getConnection();
- } catch (NamingException e) {
- System.out.println("Cannot get connection: " + e);
- } catch (SQLException e) {
- System.out.println("Cannot get connection: " + e);
- }
- return conn;
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <WatchedResource>WEB-INF/web.xml</WatchedResource>
- <WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
- <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
- <Resource url="jdbc:mysql://db:3306/joinmyparty"
- driverClassName="com.mysql.jdbc.Driver" password="mypassword"
- username="myusername" maxWait="10000" maxIdle="30"
- maxActive="100" type="javax.sql.DataSource" auth="Container"
- name="jdbc/joinmyparty" validationQuery="select 1" testOnBorrow="true"/>
- </Context>
- description : this server has encountered an internal error which prevents it from fulfilling your request
- exception
- java.lang.NullPointerException
- com.picco.user.dao.UserDao.findByEmail(UserDao.java:40)
- com.picco.user.servlet.Index.doGet(Index.java:56)
- javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
- javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
- org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
- try {
- UserDao udao = new UserDao();
- User u = udao.findByEmail(myCookieVal);
- SongDao sdao = new SongDao();
- ArrayList<Song> list = sdao.getAllSongs(u.getId());
- Random rd = new Random();
- int count = udao.count();
- request.setAttribute("currentSong", list.get(rd.nextInt(list.size())));
- request.setAttribute("songList", list);
- request.setAttribute("partyCount", count);
- this.getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
- } catch(SQLException e) {
- e.printStackTrace();
- } finally {
- HsqlConnection.closeInstance();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement