i'm trying to get some values from jTable (the values in JTable are from MySQL) to JTextField.   I got "Null Pointer Exception" after selecting the row.  After i put Line BreakPoint i see that row number is get. But at the rs=ppst.executeQuery(); line it shows me NullPointerException.   What's wrong?  here is my code:  private void jTableStudentaiMouseClicked(java.awt.event.MouseEvent evt) {                                                      try{             int row = jTableStudentai.getSelectedRow();             String Table_click = (jTableStudentai.getModel().getValueAt(row, 0).toString());              String sql = "select * from studentas inner join grupė on studentas.GrupėsID=grupė.GrupėsID where StudentoNr ='"+Table_click+"'";        ppst=co.prepareStatement(sql);        rs=ppst.executeQuery();        if(rs.next()){         String add0 = rs.getString("StudentoNr");        jTextField1.setText(add0);        String add1 = rs.getString("Vardas");        jTextFieldVardas.setText(add1);        String add2 = rs.getString("Pavardė");        jTextFieldPavarde.setText(add2);        String add3 = rs.getString("EPaštas");        jTextFieldPastas.setText(add3);        }         }catch(Exception e){             JOptionPane.showMessageDialog(null, e);         }`
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?
How to show $\lim_{x \to 1} \frac{x + x^2 + \dots + x^n - n}{x - 1} = \frac{n(n + 1)}{2}$? I need to find the cardinality of the set $S$ of all infinite subsets of $\mathbb{Q}$.   It's easy to prove $\operatorname{card} S=\mathfrak c$ if you first prove that the cardinality of the set of all finite subsets of $\mathbb{Q}$ is $\aleph_0$.   But is there some other proof for the statement without using the second one (about finite subsets)? Probably there is =) Can a decision in a node of a decision tree be based on comparison between 2 columns of the dataset? Assume the features in the dataframe are columns - A,B,C and my target is Y  Can my decision tree have a decision node which looks for say, if A&gt;B then true else false? My current prompt is colorized and edited as so -  #!/bin/bash  # GIT Prompt help if tput setaf 1 &amp;&gt; /dev/null; then     tput sgr0; # reset colors     bold=$(tput bold);     reset=$(tput sgr0);     txtund=$(tput sgr 0 1);     black=$(tput setaf 0);     blue=$(tput setaf 33);     cyan=$(tput setaf 37);     green=$(tput setaf 64);     orange=$(tput setaf 166);     purple=$(tput setaf 125);     red=$(tput setaf 124);     violet=$(tput setaf 61);     white=$(tput setaf 15);     yellow=$(tput setaf 136); else     bold='';     reset="\e[0m";     black="\e[1;30m";     blue="\e[1;34m";     cyan="\e[1;36m";     green="\e[1;32m";     orange="\e[1;33m";     purple="\e[1;35m";     red="\e[1;31m";     violet="\e[1;35m";     white="\e[1;37m";     yellow="\e[1;33m"; fi; ORIG=$PS1 HOST=$HOSTNAME PS1="\[${txtund}${green}\]${HOST}\[\[${reset}\]"; PS1+="\$(prompt_git \"\[${white}\] on \[${violet}\]\")"; PS1+="\[${reset}\]"; PS1+="\[ at - ${orange}\W\]"; PS1+="\[${reset}\]"; PS1+="\[ - \u \]"; PS1+="\n\$ ";   I know that the line  PS1+="[ - \u ]"; will show me my current user. However, I want that section to be red if it is root. All other users should be the default color of gray. Is there a way to change the color in that section based off of current user or should I just declare a variable and use an IF statement to insert that section or a modified section with red as a color?  My expected output is gray named user for all normal users. Root should be red. This is BASH. Adjoint pairs, triplets and quadruplets Often we have adjoint pairs $(A, B)$ (meaning $A$ is left adjoint to $B$). Sometimes we have adjoint triplets $(A,B,C)$ (meaning $A$ is left adjoint to $B$ and $B$ is left adjoint to $C$. No adjoint relation between $A$ and $C$ obviously, since they have the same source and target).  So the first question is: can we have quadruplets $(A,B,C,D)$ ? (meaning that $C$ is also left adjoint to $D$).  Second question: It would be then possible that we have $(A,D)$ besides $(A,B)$. But I think not, because I think that it is not possible to have a functor $A$ with two different right adjoints, $B$ and $D$. Is this correct? As a new user without much rep, what should I do if someone else has already asked a question I have, but it has no answers? How to use EntityFieldQuery with dates? I need to select entities with specific dates.   How should the following be formatted. Do I need to parse 15-May-2010  Also how I get the error page.   function events2() {  $query = new EntityFieldQuery(); $query   -&gt;entityCondition('entity_type', 'node', '=')   -&gt;propertyCondition('status', 1, '=')   -&gt;propertyCondition('type', 'event')     -&gt;propertyCondition('field_event_date', '15-May-2010', '=');  $result = $query-&gt;execute();   return $result;  } linebreak in description title I don't think I ever understood the rationale behind this.  I get that the dot product $\mathbf{a} \cdot  \mathbf{b} =\lVert \mathbf{a}\rVert \cdot\lVert \mathbf{b}\rVert \cos\theta$ is derived from the cosine rule. (Do correct me if I'm wrong.)  However, I never really understood why $\mathbf{a} \times  \mathbf{b} =\lVert \mathbf{a}\rVert \cdot\lVert \mathbf{b} \rVert \sin\theta$. Is there a proof for this?  In addition, how does the vector cross product lead to orthogonal vectors?  I remember learning that they do and I know how to solve equations using the respective formulas, but I never got why is it so. Can you catch a native exception in C# code? In C# code can you catch a native exception thrown from deep in some unmanaged library? If so do you need to do anything differently to catch it or does a standard try...catch get it? Directing Domain to Hosting Directory I just purchased a domain on Dreamhost, let's say foo.com. I already have hosting, let's say at 123.4.56.789, and have setup a directory foo.com which is accessible at 123.4.56.789/foo.com/. I can set the DNS to point foo.com to that IP, but how do I route it to that folder once it's there? My hosting has a really bad cPanel that gives me almost no help. Can I use .htaccess, or something else? What's the best way to accomplish this?  Edit in response to comment(s): It's VPS hosting, so I have access to http.conf and other system files. Also, yes it's Apache. Dimension of Dirac $\gamma$ matrices While studying the Dirac equation, I came across this enigmatic passage on p. 551 in From Classical to Quantum Mechanics by G. Esposito, G. Marmo, G. Sudarshan regarding the $\gamma$ matrices:     $$\tag{16.1.2} (\gamma^0)^2 = I , (\gamma^j)^2 = -I \ (j=1,2,3) $$    $$\tag{16.1.3}  \gamma^0\gamma^j + \gamma^j \gamma^0 = 0 $$   $$\tag{16.1.4}  \gamma^j \gamma^k + \gamma^k \gamma^j = 0, \ j\neq k$$    In looking for solutions of these equations in terms of matrices, one finds that they must have as order a multiple of 4, and that there exists a solution of order 4.   Obviously the word order here means dimension. In my QM classes the lecturer referenced chapter 5 from Advanced Quantum Mechanics by F. Schwabl, especially as regards the dimension of Dirac $\gamma$ matrices. However there it is stated only that, since the number of positive and negative eigenvalues of $\alpha$ and $\beta^k$ must be equal, $n$ is even. Moreover, $n=2$ is not sufficient, so $n=4$ is the smallest possible dimension in which it is possible to realize the desired algebraic structure.  While I got that the smallest dimension is 4, I fail to find any argument to reject the possibility that $n=6$ could be a solution. I also checked  Phys.SE post, but I didn't find it helpful at all.  Can anyone help me? I want to be able to  write the following in LaTeX      We make the further assumption that \begin{equation} \label{eqn:assumption} There is a bounded linear operator     $B:X\to X^*$ such that $B^*=B$ and the operator $JB$ is an extension of $T'(0)$\end{equation}   and get a nice output, in such a way that this whole chunk of text along with the math can be referenced later. Of course I can write text inside the equation environment using \text{}, but when I tried this the spacing was all wrong. Can anyone suggest a solution to this? Get PHP to stop replacing '.' characters in $_GET or $_POST arrays? If I pass PHP variables with . in their names via $_GET PHP auto-replaces them with _ characters. For example:  &lt;?php echo "url is ".$_SERVER['REQUEST_URI']."&lt;p&gt;"; echo "x.y is ".$_GET['x.y'].".&lt;p&gt;"; echo "x_y is ".$_GET['x_y'].".&lt;p&gt;";   ... outputs the following:  url is /SpShipTool/php/testGetUrl.php?x.y=a.b x.y is . x_y is a.b.   ... my question is this: is there any way I can get this to stop? Cannot for the life of me figure out what I've done to deserve this  PHP version I'm running with is 5.2.4-2ubuntu5.3. Serial protocol delimiting/synchronization techniques As asynchronous serial communication is widely spread among electronic devices even nowadays, I believe many of us have encountered such a question from time to time. Consider an electronic device D and a computer PC connected with serial line (RS-232 or similar) and required to exchange information continuously. I.e. PC is sending a command frame each X ms, and D is replying with status report/telemetry frame each Y ms (The report can be sent as response to requests or independently - doesn't really matter here). The communication frames can contain any arbitrary binary data. Assuming the communication frames are fixed-length packets. The problem: As the protocol is continuous, the receiving side might loose the synchronization or just &quot;join&quot; in the middle of an ongoing sent frame, so it just won't know where the start of frame (SOF) is. A the data has different meaning based on its position relatively to the SOF, the received data will become corrupted, potentially forever. The required solution Reliable delimiting/synchronization scheme to detect the SOF with short recovery time (i.e. it shouldn't take more than, say 1 frame to resynchronize). The existing techniques I am aware (and using some) of: 1) Header / checksum - SOF as predefined byte value. Checksum in the end of frame.  Pros: Simple. Cons: Not reliable. Unknown recovery time.  2) Byte stuffing:  Pros: Reliable, fast recovery, can be used with any hardware Cons: Not that suitable for fixed-size frame-based communication  3) 9th bit marking - prepend each byte with additional bit, while SOF marked with 1 and the data bytes are marked with 0:  Pros: Reliable, fast recovery Cons: Requires hardware support. Not directly supported by most of PC hardware and software.  4) 8th bit marking - kind of emulation of the above, while using the 8th bit instead of 9th, which is leaving only 7bits for each data word.  Pros: Reliable, fast recovery, can be used with any hardware. Cons: Requires an encoding/decoding scheme from/to the conventional 8-bit representation to/from 7-bit representation. Somewhat wasteful.  5) Timeout based - assume the SOF as the first byte coming after some defined idle time.  Pros: No data overhead, simple. Cons: Not that reliable. Won't work well with poor timing systems like, say, Windows PC. Potential throughput overhead.  Question: What are the other possible techniques/solutions exist to address the problem? Can you point to the cons in the above list which can be easily worked around, thus removing them? How do you (or would you) design your systems protocol? What is the name for moments, a parameter that is calculated Initializing K-means centers by the means of random subsamples of the dataset? If I have a certain dataset, how smart would it be to initialize cluster centers using means of random samples of that dataset?  For example, suppose I want 5 clusters. I take 5 random samples of say, size=20% of the original dataset. Could I then take the mean of each of these 5 random samples and use those means as my 5 initial cluster centers? I don't know where I read this but I wanted to know what you guys think about the idea.    UPDATE: Please see this thread  for the general discussion about the various initialization methods. I installed Windows on my computer, followed by an installation of Ubuntu. However, now I'm unable to boot into my Windows install.  What can I do to fix this? Prove normal matrix is 4th power of some self-adjoint matrix Let $A\in\mathbb{M}_n(\mathbb{C})$ be a matrix of order $n\geq 2$. Let $p_A(x) = (x-\lambda_1)\cdots (x-\lambda_n)$ be the characteristic polynomial of $A$ such that all $\lambda_i$ are positive real numbers.  Suppose that $A$ is a normal matrix. Prove that one can write $A=G^4$ for some self-adjoint matrix $G$.  My thinking is that since $A$ is normal, by Principal Axis Theorem, we have $A=UDU^\ast$, where $U$ is a unitary matrix and $D$ a diagonal matrix. However, I fail to see how to proceed. Could anyone help me out? Suppose that $(s_n)$ converges to $s$, $(t_n)$ converges to $t$, and $s_n \leq t_n \: \forall \: n$. Prove that $s \leq t$. I'm stuck with the proof of the following:  Suppose that $(s_n)$ converges to $s$, $(t_n)$ converges to $t$, and $s_n \leq t_n \: \forall \: n$. Prove that $s \leq t$.   I've tried starting with $s_n \leq t_n \: \forall : n$ and the definitions of each limit (i.e. $|s_n - s| \leq \epsilon \: \forall \: n &gt; N_1$), but I'm not really getting very far. Any help is appreciated!