so I'm trying to connect to my database from java, I'm working in Eclipse, I watched a tutorial online and everything seemed to be working perfectly !!.. but when I wanted to connect another database on appache server.. the program starts running.. but nothing happens for a few minutes.. then I get the Null Pointer Exception message.. and at the line : st = con.createStatement(); this is the code:  package database_console;      import java.sql.*      public class DBConnect { private  Connection con; private  Statement st; private ResultSet rs;  public DBConnect(){      try {         Class.forName("com.mysql.jdbc.Driver");               try {                 con = DriverManager.getConnection("jdbc:mysql://localhost:80/mysql", "root", "admin");                 st = con.createStatement();             } catch (SQLException e) {                 // TODO Auto-generated catch block                 e.printStackTrace();             }     } catch (ClassNotFoundException e) {         // TODO Auto-generated catch block         e.printStackTrace();     } }  // to retrieve the results and print them out public void getData(){      String query = "select DB from db";     try {         rs = st.executeQuery(query);         System.out.print("Records from Database");          while (rs.next()){             String DB = rs.getString("DB");             //String name = rs.getString("name");             //String password = rs.getString("password");             //int id = rs.getInt("id");             //System.out.print("ID: "+id+" Name: "+name+" password: "+password+"");             System.out.print("DB: " + DB );         }         st.close();     } catch (SQLException e) {         // TODO Auto-generated catch block         e.printStackTrace();     } }   I later call the getData() function from another class where the main() is:  package database_console;  import java.io.IOException;  public class Main {  public static void main(String[] args){     DBConnect connect = new DBConnect();     connect.getData(); }   can u help me figure out what's wrong with my code? thanks.
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?
Can older cards that refer to a player/opponent ever be used on planeswalkers? Many older cards refer to players or opponents, e.g. "deal 3 damage to target player". Can any of these be used on planeswalkers, beyond the fact that you can simply attack them with creatures?  For example:   Would my opponent discard a card if  damaged a planeswalker they control? Would my opponent, the planeswalker, neither, or both amass poison counters from an unblocked ? Can  target a planeswalker? Does  affect planeswalkers? Can  prevent damage to a Planeswalker? Would  be obligated to take damage being dealt to a planeswalker? Can a planeswalker gain loyalty from ? Can  prevent damage to a planeswalker? Installing Kali on a USB drive - NOT Live USB or Persistence partition Greeting's, to clarify; my question is not creating a Live USB drive or a persistence partition but creating a USB with GRUB bootloader (or other) and Kali which can be used on any machine. This is similar to running other linux OS directly from USB. I am currently running Ubuntu from a pen drive. I installed the OS (Ubuntu) and the bootloader on the pen drive and I can boot off it anywhere. Here is a video explaining the same (video is not by me: )  Since, Kali's installer doesn't give option to select which drive to write the booloader to and directly writes on the HDD (sda1). This means even if I partition and install Kali on a pen drive since the bootloader will be installed on the machines fixed primary drive, the USB drive will fail to boot on a different device.  I have two questions:   Anyone has any idea how to write bootloader to a USB drive and what parameters should be given so that it boots with Kali installed on it. I am using graphic install mode for installing Kali on the USB drive, however there is no option for the install to be encrypted (Full disk encryption or at least /home folder to be encrypted). Does anyone know how can I install Kali with full disk / home folder encryption? Or enable is post install?   Thank You! How does DES decryption work? Is it the same as encryption or the reverse? If DES decryption is the same as encryption done in reverse order, then how can the reversed S-Box convert 4 bits into 6 bits? PHP function substr() error I want to play a game in an older update, but can't see a way to choose a specific version. Is this possible? Java - Could not find the main class The  page says that Box-Jenkins is a method of fitting an ARIMA model to a time series. Now, if I want to fit an ARIMA model to a time series, I will open up SAS, call proc ARIMA, supply the parameters $p,d,q$ and SAS will give me AR and MA coefficients. Now, I can try different combinations of $p,d,q$ and SAS will give me a set of coefficients in each case. I select the set with the lowest Akaike information criterion.  My question is: where in the above procedure did I use Box-Jenkins? Am I supposed to use Box-Jenkins to come up with initial estimates of $p,d,q$? Or did SAS use it internally somehow? I have Sanguinare Vampiris. I don't really want to become a vampire. How can I cure myself? Must a husband and wife make separate online applications for a UK Standard Visitor visa, and so attend separate appointments for biometrics? Earth Engine convert list with coordinates and values into a feature collection for export I need to create a feature collection from a list containing coordinates and band values.  These are extracted from a landsat image as shown in this linked script.    I'm unable to find a solution in creating a feature collection.  Here is the tail end code.  var valuesList = joinedImage.reduceRegion({   reducer: ee.Reducer.toList(4),   geometry: myGeometry }).values().get(0);  var feature = ee.Feature(null, valuesList);   // Wrap the Feature in a FeatureCollection for export. var myFeatures = ee.FeatureCollection([feature]);   // Export the image, specifying scale and region. Export.table.toDrive(myFeatures, "data", "myData", "B4-B5",  "CSV");   This doesn't work, because it is clearly the wrong way to create the feature collection.  I've tried to create it similar to Rodrigo E. Principe's solution of mapping a Feature Collection but I can't seem to create the initial feature collection to start with. Why do the less than symbol () appear wrong as upside down exclamation (¡) or question mark (¿)? What's the incentive to flag duplicates? Loading .sql files from within PHP The Many Memes of Meta Catchphrases and concepts that spread from person to person are known as [memes], which, courtesy the Internet, can now explode across the Earth like a highly contagious virus (hence &quot;going viral&quot;). As with their real-life counterparts, some infectious diseases are global (pandemic), while others are endemic to specific regions. Stack Overflow, and now even more predominantly Meta Stack Exchange, have seen more than their fair share of these pathological social constructs spread through the user base. They are now ingrained units of our collective culture as SOpedians (a term which I hate, by the way). Just as travelers' immune systems can be assaulted by new diseases in new places, new users are increasingly likely to be miffed by an ingrained meme and left sitting scratching their heads. I therefore propose that this space be used to document the memes endemic to Stack Exchange's culture. Each meme should be listed in a separate answer and I hope that we as a community will be able to provide greater context to each one. Please actually explain each meme in a way understandable to those not already in the know. Especially considering that a lot of these memes aren't really understandable to newer users who weren't around in the early years of the network, or are based on system features that no longer exist.  On other Stack Exchange sites          [memes]: How can I check if an application is running from a batch (well cmd) file?  I need to not launch another instance if a program is already running. (I can't change the app to make it single instance only.)  Also the application could be running as any user. How to Pivot Multiple Columns in SQL Server I've read many posts about using pivot to get the data in the format I want, but the more I read the more confused I get.  I have this data:    That I'm trying to get into a format similar to this:   For the most part, everything I try results in an SQL error, and the only successful attempt I've had didn't return the data in the format I'm looking for.  Any help would be appreciated. Restore default apt repositories in sources.list from command line I am looking for the best method to restore /etc/apt/sources.list to default from the command line.  Is there no way to reference the source code of the package which generates this file or something like that? I want a trusted and version-independent way of restoring this file.  Solutions Ruled Out  Before you mark this as a duplicate, note that I have reviewed  already. It is only applicable if you have the Ubuntu GUI available. This question is specific to the command line.  I have also reviewed  where the accepted solution is someone pasted the contents of their sources.list file. This is not an appropriate way to restore the file as the intentions of the person providing the file contents cannot be verified and the file is subject to change with new releases.  I checked out the , but this is also not from Ubuntu so I do not plan to use it. How to run a program without typing the full path? System utilities such as ls don't need to have the full path typed before executing them. However, to execute Netbeans, I have to type /home/chris/netbeans-7.0.1/bin/netbeans. How can I make it so that I only have to type netbeans? "Give a hand" vs "Help" Currently, I'm working in an international company with many non-native speakers (so am I) but with pretty good level of English, I suppose.  I have noticed that my colleagues usually use phrase "give a hand" when asking for  help or even talking about it and seems to be avoiding the strong word "help".  It looks a bit confusing to me especially after I made people laugh when I said  "I will help you" in one of our conversations, don't remember exact context though...  So could you please describe the difference between them? And is there something wrong or hidden meaning with help-based phrase? Front facing camera stopped working on the iPhone 4s