Spring jdbcTemplate null pointer exception I'm trying to use jdbcTemplate to execute sql commands. In this case, I'm trying to insert things into a table. I'm getting a null pointer exception in the line : jdbcTemplate.execute(subscriptionStatusInsertQuery);  When I try to run the line: dbMapper.mapToDatabase(newEntry); where dbMapper is an instance of DBMapper.  @Repository public class DBMapper {      private JdbcTemplate jdbcTemplate;      public JdbcTemplate getJdbcTemplate() {         return jdbcTemplate;     }      @Autowired     public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {         this.jdbcTemplate = jdbcTemplate;     }      public void mapToDatabase(Status status) {         String id = status.getId();          String subscriptionStatusInsertQuery = "INSERT INTO t1 (ID) VALUES (id)";         jdbcTemplate.execute(subscriptionStatusInsertQuery);     } }   I've tried not having a setter for jdbcTemplate. I've tried taking out the @Repository annotation. I've tried having a setter that included datasource. Still getting error.  How should I fix this null pointer exception?  Edit:  My application.properties has the following setting:  spring.datasource.url=jdbc:mysql://localhost:3306/ee_internal spring.datasource.username=ee spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.password=mypassword spring.datasource.test-on-borrow=true spring.datasource.validation-query=SELECT 1   And from my pom.xml:  &lt;dependency&gt;             &lt;groupId&gt;org.springframework&lt;/groupId&gt;             &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;         &lt;/dependency&gt;
What is a NullPointerException, and how do I fix it? 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?
Why current in series circuit is the same? I have read in the internet that the charges do not have any other path to go and they must go through the same in a series circuit,hence the current is same.  It was quite convincing but what confused me was: "A resistor is a passive two-terminal electrical component that implements electrical resistance as a circuit element. Resistors act to reduce current flow..."(according to the Wikipedia). This means that the resistors slow down the rate of flow of charges. By definition, electric current is the rate of flow of charges. Then must not the current be reduced in a resistor even when the amount of charge is same? Is it possible to create a URL link to a website on the home screen? Is it necessary to close StringIO in ruby? It's taken me almost 10 years of Linux usage to ask this question. It was all trial and error and random late-night internet surfing.  But people shouldn't need 10 years for this. If I were just starting out with Linux, I'd want to know: When to alias, when to script, and when to write a function?  Where aliases are concerned, I use aliases for very simple operations that don't take arguments.   alias houston='cd /home/username/.scripts/'   That seems obvious. But some people do this:  alias command="bash bashscriptname"   (and add it to the .bashrc file)   Is there a good reason to do that? I'm trying really hard, but I genuinely can't think of any circumstances in which I'd want to do that. So, if there is an edge case where that would make a difference, please answer below.  Because that's where I would just put something in my PATH and chmod +x it, which is another thing that came after years of Linux trial-and-error.  Which brings me to the next topic. For instance, I added a hidden folder (.scripts/) in the home directory to my PATH by just adding a line to my .bashrc (PATH=$PATH:/home/username/.scripts/), so anything executable in there automagically autocompletes.  If I needed to.  I don't really need that, though, do I? I would only use that for languages that are not the shell, like Python.  If it's the shell, I can just write a function inside the very same .bashrc:  funcname () {   somecommand -someARGS "$@" }   As I stated, I found a lot of this out through trial and error. And I only truly saw the beauty of functions when my computer died and I was forced to use the computers of the people around me when they weren't using them.   Instead of moving a whole directory of scripts from computer to computer, I ended up just replacing everyone else's .bashrc with my own, since they had never even made a single modification.  But did I miss anything?   So, what would you tell a beginning Linux user about when to alias, when to script, and when to write a function?   If it's not obvious, I'm assuming the people who answer this will make use of all three options. If you only use aliases, or only use scripts, or only use functions—or if you only use aliases and scripts or aliases and functions or scripts and functions—this question isn't really aimed at you. How to reverse the direction of the y axes Number of moves necessary to solve Rubik's cube by pure chance Suppose, random moves are made to solve Rubik's cube. A move consists of a $90$-degree-rotation of some side. The starting position is also random.   What is $E(X)$, where $X$ is the number of moves until the cube is solved ? How many moves must be made, that the probability that the cube is solved, exceeds $99$% ? Can I charge a computer through its USB port? What is polarisation, spin, helicity, chirality and parity? Polarisation, spin, helicity, chirality and parity keep confusing me. They seem to be related, but exactly how they are related is unclear to me. Can someone maybe give a short overview about what these quantities mean and how they are related? What are the values for e.g. basic particles like electron or photon? Show that every large integer has a large prime-power factor  That is, if $P(n)$ designates the largest number $p^a$ which divides $n$, then $\lim_{n\to\infty}P(n)=\infty.$ Allow Documentation in other Stack Exchange communities I'm a Salesforce developer and would love Documentation to be available in other Stack Exchange communities. The reason is  a lot of Salesforce developers get help, especially newer ones like myself. The developer forums and documentation on  is mediocre. It would be nice to allow users to create their own and give pack on how I can draw an skew cylinder (rotate around x axis) and fill it (in 3D tikz)? I am using Windows 10. I am trying to install 1 open source software.  In the readme.txt of that software, it says it requires Visual C++ 2008 Redistributable. I found that my Windows already has Visual Studio 2012 Redistributable installed.  After I install the open source software, it seems that it is working, even though I haven't installed Visual C++ 2008 Redistributable.  Do I need to install Visual C++ 2008 Redistributable if my Windows already has Visual Studio 2012 Redistributable? Suppose that we don't know logarithm, then how we would able to calculate $\sqrt x$, where $x$ is a real number? More generally, is there any algorithm to calculate $\sqrt [ n ]{ x } $ without using logarithm? More simple techniques would be nice.  Here is a simple technique used to approximate square roots by :  For example: $\sqrt {78}\approx 8\frac { 14 }{ 17 } $ , where $8$ is the nearest integer root of $78$, $14 = 78 - 8^2$, $17 = 2 \times 8 + 1$.  if $n=2^k$ we can use the method above.   For example, for $k=2$ Lets calculate $\sqrt [ 4 ]{ 136 } $: $$\sqrt [ 4 ]{ 136 } =\sqrt { \sqrt { 136 }  } \approx \sqrt { 11\frac { 136-{ 11 }^{ 2 } }{ 11\times 2+1 }  } =\sqrt { 11\frac { 15 }{ 23 }  } \\ \sqrt { 11\frac { 15 }{ 23 }  } \approx 3\frac { 11\frac { 15 }{ 23 } -{ 3 }^{ 2 } }{ 3\times 2+1 } =\frac { 544 }{ 161 } =3.38\\$$ The exact result is$$ \sqrt [ 4 ]{ 136 } =3.4149\cdots$$ The method approximates well, but it is working for only $n=2^k$ as I know. So, I have about 7 actions users may need in my app, and I have to use text instead of icons because it is a customer requirement.  I can add only 3 actions to my toolbar on iPhone 6. On Android you have the hamburger menu (see image), but I have never seen it in iOS.       So, what is the appropriate concept in iOS to add many actions into a menu? I'm currently the proud owner of Frost the horse. What I want to know is, what will happen to him if I ride another horse?  Obviously nothing will happen as long as I have him in sight, e.g. I'll be able to ride Frost to make him my horse again.  Scenarios  But what will happen if, before I get back on Frost, I fast travel somewhere? Will he return to where I originally stole him, will he disappear forever, or can I own two horses simultaneously?  Ownership?  If he goes back to where I originally stole him, will I have to steal him again, and therefore never be his true owner again?  Two Horses?  The reason I'm asking is because I want to get Shadowmere (the Dark Brotherhood horse) while keeping Frost. Is it possible to do this, or will riding Shadowmere make me lose Frost forever? Take an FF body and a crop body, with similar MP rating - and the FF body will give a sharper image of the same object. At least, that seems to be the case - as here:    I assume a low ISO was used in both images.  Why does the FF body, with the same lens and almost the same MP, give an image that is so much sharper?   My best guess is that the diffraction / airy still play a role, and the larger pixels reduce effective overlap - thus increasing contrast/sharpness by displaying less of the neighboring diffraction, as below? Running two MySQL servers that use the same data directory I have a very large folder that I am trying to create a tar archive of. The issue is I don't have enough extra free space to store the entire archive so I want to create say 100-200GB chunks of the archive at a time and transfer those individually to cloud storage. I need to be able to control when new chunks are created so my HDD doesn't fill up but all of the commands i've found to create split tarballs always create it all at once, in the same directory. The closest solution I found was from  but all the responses base the archives on number of files, not size which is important for my use case as my file sizes are unevenly distributed. SVN Error - Not a working copy Recently our svn server was changed and we did a svn switch.  Since the working copy had a huge amount of unversioned resources, the working copy got locked and we started switching folder by folder for all folders under svn, which works perfectly fine.  But at the top most level of the repository, when I try to update files, I get the svn: Working copy '.' locked error and cleanup is not helping either. When I do cleanup, I get errors like these - svn: 'content' is not a working copy directory  Fresh checkout is NOT an option at all. Are there any other ways to cleanup and release the locks and do the switch completely ?  EDIT:  The last paragraph in JesperE's answer     If you get a "not a working copy" when   doing a recursive "svn cleanup" my   guess is that you have a directory   which should be a working copy (i.e.   the .svn directory at the toplevel   says so), but it is missing its own   .svn directory. In that case, you   could try to just remove/move that   directory and then do a local update   seems to be the solution to the problem in the repository. I have identified those folders and did a fresh checkout of those specific folders alone and wow, the locks are released in the subsequent cleanup! Thanks a lot JesperE !!  But, I still cannot figure out the svn switch error which now reads something like,     svn: The repository at   'svn://repourl/reponame/foldername'   has uuid 'm/reponame', but the WC   has 'b5b39681-0ff6-784b-ad26-2846b9ea8e7d'   Any ideas ? I would like to know how can I customize the Ubuntu installer NOT customize Ubuntu, I just want to modify the installer.  We have a large environment here with lots of developers and since we don't use Windows, I want to customize the installer to automatically set the timezone to NYC, the keyboard layout to English USA, put the company logo in the installer etc...