Hi i wrote this java webservice but i get a NullPointerException out of executeFetchQuery? What is causing this NullPointer. I thought the connection could not be made because of this error: Error executeFetchQuery: java.lang.NullPointerException  package nl.jorisdek.dinnerspinner.business;  import java.sql.*; import java.util.ArrayList; import javax.sql.DataSource; import javax.annotation.Resource; import javax.ejb.LocalBean; import javax.ejb.Stateless;  /**  *  * @author Joris  */ @Stateless @LocalBean public class DbConnect {     @Resource(name = "jdbc/dinnerspinner")     private DataSource ds;     private Statement st;     private PreparedStatement pst;      public DbConnect(){     }      public void executeModifyQuery(String sql) {          try{             Connection con = ds.getConnection();             con.createStatement().execute(sql);             con.close();         } catch(Exception ex) {             System.out.println("Error: "+ ex);         }     }       public ResultSet executeFetchQuery(String sql) {         ResultSet rs = null;         try {             Connection con = ds.getConnection();             rs = con.createStatement().executeQuery(sql);             con.close();         }         catch(Exception ex) {             System.out.println("Error executeFetchQuery: "+ ex);         }          System.out.println("rs: "+rs);         return rs;     }        public ArrayList&lt;Dishes&gt; getDishes() {         //Map json = new HashMap();           ArrayList&lt;Dishes&gt; dishes = new ArrayList&lt;&gt;();         String sql = "SELECT * FROM dishes";         ResultSet rs = executeFetchQuery(sql);         //ResultSetMetaData metaData = rs.getMetaData();         try {                         while(rs.next()){                 Dishes dish = new Dishes();                  dish.setId(rs.getInt("id"));                 dish.setNaam(rs.getString("naam"));                 dish.setWinkel(rs.getString("winkel"));                 dish.setIngredienten(rs.getString("ingredienten"));                 dish.setExtra(rs.getString("extra"));                 dish.setKosten(rs.getDouble("kosten"));                 dish.setBereiding(rs.getString("bereiding"));                 dish.setGezond(rs.getBoolean("gezond"));                 dish.setGoedkoop(rs.getBoolean("goedkoop"));                 dish.setSimpel(rs.getBoolean("simpel"));                 dish.setSnel(rs.getBoolean("snel"));                  dishes.add(dish);              }         } catch(Exception ex) {             System.out.println("Error getDishes: "+ ex);         }          return dishes;     }  }   I think you need this   java.lang.NullPointerException     at nl.jorisdek.dinnerspinner.DishesSoap.getDishes(DishesSoap.java:35)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Does $E = mc^2$ apply to photons? Photons are massless, but if $m = 0$ and , then $E = 0c^2 = 0$. This would say that photons have no energy, which is not true.  However, given the formula $E = ℎf$, a photon does have energy as $ℎ$ is a non-zero constant and photons with a zero frequency do not exist.  What am I missing here, or does the famous formula not apply to photons? Integral of periodic function over the length of the period is the same everywhere Why do games run slow on CPU Maybe my question sounds naive because I'm not a game developer but I dont see objective reasons for this. An average cpu is in times more powerful than an average gpu like a few graphics cards in one. The most repeated reasons in internet:  the GPU isn't as busy as the CPU  If the gpu renders the screen how it can not be busy The modern cpus are powerful enough. They are not busy most of time. For example my cpu's usage is 3%.  many GPU's are designed to process graphics commands in parallel, CPU single threads them  What bothers the games to run a few parallel processes even on one cpu core? In my opinion its not correct to tell that the gpu is better if games never use 100% of the cpu's capacity. To be specific they dont use even 50%.  To clarify my question based on responses in the comments:  Did you mean to ask &quot;Why do games render more slowly on the CPU?&quot;  Yes I mean why the cpu cant do the whole work for games when it is underloaded and especially if it does the largest part of work in any case.  You can not compare GPUs and CPUs directly, because they do different things.  What bothers them to do the same things?  The CPU isn't as well suited to performing rendering calculations  I dont understand what &quot;suited&quot; means. And why the cpu is not suitable for primitive tasks aka paint roller.  adding additional parallel processes doesn't improve performance  Then why do you produce multicore graphics cards and multicore central processing units? Just give various parts of one task to a few processes if one process is slow and 100% of the capacity is not used. What bothers to emulate the gpu? Its also unclear for me why when you play without a separate graphics module the games see only one cpu core when you play with the gpu they see and use all the cpu cores. May be some magic. Find the limit $\lim_{n\rightarrow\infty}\sum_{k=1}^{n}\frac{1}{k+n}$ $$\lim_{n\rightarrow\infty}\sum_{k=1}^{n}\frac{1}{k+n}$$  Could you please give me a hint how to find this limit? Ignore citations in captions in list of figures when numbering When using the \cite command in figure captions and the ieeetr bibliography style, then  BibTeX numbers the citations as appearing earlier than they do in reality (i.e. the first citation in the document ends up being [42]).  Is there any way to get BibTeX to ignore the \listoffigures section when numbering? Projection is an open map Let $X$ and $Y$ be (any) topological spaces. Show that the projection  $\pi_1$ : $X\times Y\to X$   is an open map. What Happened to The Latex Symbols In the Libreoffice-Texmaths Equation Editor? I recently purged Libreoffice because it was buggy.  I then reinstalled the latest version from apt and now it's missing the symbols above the equation editor.  Here is the current Texmaths equation editor:   There used to be shortcuts for latex including frac{}{} and various set theory operations, as well as the binomial distribution on the top of the window.  What happened to them and how do I get them back? I just figured that they were in some package and installed all packages useing sudo apt install libreoffice*, but this didn't help after I refreshed the program.  EDIT 0: I'm using Kubuntu 19.04  sarah@LesserArk:~$ sudo apt-cache policy libreoffice-texmaths libreoffice-writer texlive libreoffice-texmaths:   Installed: 0.43-2   Candidate: 0.43-2   Version table:  *** 0.43-2 500         500 http://us.archive.ubuntu.com/ubuntu disco/universe amd64 Packages         500 http://us.archive.ubuntu.com/ubuntu disco/universe i386 Packages         100 /var/lib/dpkg/status libreoffice-writer:   Installed: 1:6.2.2-0ubuntu2   Candidate: 1:6.2.2-0ubuntu2   Version table:  *** 1:6.2.2-0ubuntu2 500         500 http://us.archive.ubuntu.com/ubuntu disco/main amd64 Packages         100 /var/lib/dpkg/status texlive:   Installed: 2018.20190227-1   Candidate: 2018.20190227-1   Version table:  *** 2018.20190227-1 500         500 http://us.archive.ubuntu.com/ubuntu disco/universe amd64 Packages         500 http://us.archive.ubuntu.com/ubuntu disco/universe i386 Packages         100 /var/lib/dpkg/status Convergence to a Uniform Distribution $\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor} $  Show that if $P(X_n = i/n)=1/n$ for every $i = 1,...,n$, then $X_n$ converges in distribution to a uniformly distributed random variable $X$.  Convergence in distribution is defined as   $$P(X_n \leq x) \rightarrow P(X \leq x)$$  and I have that a uniform distribution with parameters $a$ and $b$ implies that  $$P(X \leq x) = \frac{x-a}{b-a}$$  I cannot go any further however. I feel like I don't know anything about $X_n$ - I don't even know if it is continuous or discrete. What I can just say is that   $$P(X_n \leq x) = \sum_{i=1}^\floor{x} \frac{1}{n}$$  where $\floor{x}$  means rounding $x$ to the closest lower integer. For $f$ in dual space, there exists $x$ with norm 1 and $f(x)=\|f\|$ if space is reflexive (and nontrivial) Let $X\ne\{0\}$ be a reflexive space and let $f\in X^*$, where $X^*$ is the dual of $X$. I want to know: in general, does there exist an $x\in X$ with $\|x\|=1$, and $f(x)=\|f\|$, where $\|f\|$ is defined as $\sup\{|f(x)|:x\in X,\|x\|=1\}$?  I know this is true for $\mathbb{R}^n$ with the norm from the standard inner product, but I'm wondering if it is true in general. I'm working on a VAR model and am doing a log transformation of the raw data.   x = log(x)   After differencing, running various tests and running a VAR(2) model, I add the predicted differences cumulatively to the original time series (logged) like this:  prd.diffs &lt;- as.ts(prd$mean$d.x1) U &lt;- tail(undiff,2) cumu &lt;- cumsum(prd.diffs) + U[1]   However, while the output now looks as it should, it is still in logged values.  My question is as follows:  How does one return the logged output to original values? I'm under the impression that using exp() will not give the correct results, and having tried some variations it hasn't worked for me.   Does the fact that it is a VAR($p$) model (and possibly what lag it has) influence the method, and how should that be implemented to get the correct output?  P.S. I realise that the above code does not constitute a replicable example as I didn't deem that necessary for the question, but should that be desired I can add some more code. While CtrlX works fine in vim under windows, CtrlA selects all (duh).  Is there a way to increment a number with a keystroke under windows? I'm making a map where I want players to be able to choose there kits/classes. The problem I'm having with it though is giving players already enchanted Tools/Armour/Weapons.  I'm not sure if you can use the /give [player] [item] [amount] because you'll have to use the whole {} thing and I'm not sure how to make enchanted Tools/Armour/Weapons using that.  Can anyone help? Alternate moves, first one to roll a 6 wins: what's the probability of winning? Question: Players A and B play a sequence of independent games. Player A starts and throws a fair die and wins on a "six". If she fails then player B throws the same die and wins on a "six" or fails otherwise. If she fails then player A gets the die and throws again, and so on. The first player to throw a "six" wins. Find the probability that player A wins.  Here is what I have done:  A wins right away: $\dfrac{1}{6}$  A fails B wins: $\dfrac{5}{6}\times \dfrac{1}{6}$  A fails B fails A wins: $\dfrac{5}{6}\times \dfrac{5}{6}\times \dfrac{1}{6}$  Unlike another similar question which the player B can win on "five" and "six" after player A fails on the first throw, in this case, the games do not seem to have an endpoint. How should I calculate the probability that player A wins then? Removing elements with Array.map in JavaScript I would like to filter an array of items by using the map() function. Here is a code snippet:  var filteredItems = items.map(function(item) {     if( ...some condition... )     {         return item;     } });   The problem is that filtered out items still uses space in the array and I would like to completely wipe them out.  Any idea?  EDIT: Thanks, I forgot about filter(), what I wanted is actually a filter() then a map().  EDIT2: Thanks for pointing that map() and filter() are not implemented in all browsers, although my specific code was not intended to run in a browser. Programmatically Create X509 Certificate using OpenSSL Is it OK for OSB3 boards to get wet during construction? Why is $ the default symbol for a user shell and # the default symbol for a root shell? Operating a standard bash shell on a server, the PS1 prompt defaults to ending in a $ for non-root users, and # for root.  IE:  ubuntu@server:~$ sudo su root@server:/home/ubuntu#   Why is this? polynomial converges uniformily to analytic function Rollup Summary Trigger Help I am trying to create an Apex Trigger that performs a Rollup from a custom object to Contacts.   Here is the error that I am receiving:      Didn't understand relationship 'Assignments__r' in FROM part of query   call. If you are attempting to use a custom relationship, be sure to   append the '__r' after the custom relationship name. Please reference   your WSDL or the describe call for the appropriate names.   The child relationship name is Assignments.  Below is the code:      trigger RollupActiveAssigmentLevelsToContact on pse__Assignment__c (after insert, after update, after delete) {      set&lt;Id&gt; set_id = new set&lt;Id&gt;();      List&lt;Contact&gt; con_list = new List&lt;Contact&gt;();      if(trigger.isInsert || trigger.isUpdate){         for(pse__Assignment__c myAssignment : trigger.New) {             set_id.add(myAssignment.pse__Resource__c);         }     }     else if(trigger.isDelete){         for(pse__Assignment__c myAssignment : trigger.Old){             set_id.add(myAssignment.pse__Resource__c);         }     }      if(trigger.isAfter &amp;&amp; (trigger.isInsert || trigger.isUpdate || trigger.isDelete)){         con_list = [SELECT id,Total_Levels__c, (SELECT id,name FROM Assignments__r WHERE Active_Assignment__c = TRUE) FROM Contact WHERE id IN :set_id];          for(Contact con : con_list){             if(con.Assignments__r.size()&gt;0)                 con.Total_Levels__c = con.Assignments__r.size();             else                 con.Total_Levels__c = 0;         }         if(!con_list.isEmpty())         update con_list;     } }   Below is a snap of the Child Relationship name: The command history between sessions is not getting saved. I'm using guake and the history for the session is working fine. I noticed that .bash_history had some commands I executed in sudo -s mode and tried the same again and all the commands while in the session got saved so I tried: chmod 777 .bash_history  Now the old commands appear at the start of a session but no new commands are getting saved.