TABLE OF CONTENTS (HIDE)

Common Error Messages

JDK, MySQL, Tomcat, JDBC, Servlet ...

Murphy's Law states that:

  • "Anything that can possibly go wrong, does."
  • "Everything that can possibly go wrong will go wrong."
  • "If anything can go wrong, it will."
  • "If there is any way to do it wrong, he will."

When software goes wrong, the MOST IMPORTANT thing to do is to FIND the ERROR MESSAGE, which can give you clues of what went wrong. If things were running fine until the lightning strikes, ask yourself what have you CHANGED!

Search this document with your Error Message; or simple google your error message.

Stack Trace

Most of the times, the error message consists of tens of lines of so-called stack trace of method invocation. That is, method A called method B, which called method C, and so on, until method Z encountered an error and threw an Exception or an Error. It is important to:

  1. Get to the first line of the error message to read the description, and
  2. Look for the line number of YOUR PROGRAM that triggered the error.

For example, this error message (stack trace) has 40 over lines:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure  <== First line with error description
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
        at java.sql.DriverManager.getConnection(DriverManager.java:579)
        at java.sql.DriverManager.getConnection(DriverManager.java:221)
        at MySQLJdbcTestJDK7.main(MySQLJdbcTestJDK7.java:7)         <== Your program's line number here (line 7)
Caused by: java.net.ConnectException: Connection refused: connect   <== First line of another related error
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:337)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:180)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at java.net.Socket.<init>(Socket.java:425)
        at java.net.Socket.<init>(Socket.java:241)
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
        ... 15 more

JDBC Programming Common Errors

JDBC on MS Access

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: [Microsoft][ODBC Driver Manager] 
   Data source name not found and no default driver specified.
PROBABLE CAUSES: No such Data Source (ODBC) name in method 
   DriverManager.getConnection("jdbc:odbc:ODBCName");
POSSIBLE SOLUTION: Check your ODBC configuration (under control panel ⇒ ODBC).

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: [Microsoft][ODBC Driver Manager] No data found
PROBABLE CAUSES: The ODBCName in method DriverManager.getConnection("jdbc:odbc:ODBCName") 
   does not SELECT a database.
POSSIBLE SOLUTION: Check your ODBC configuration (under control panel ⇒ ODBC).

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 
   The Microsoft Office Access database engine cannot find the input table or query 'xxx'.  
   Make sure it exists and that its name is spelled correctly.
PROBABLE CAUSES: The SQL statement references a non-existence table.
POSSIBLE SOLUTION: Check your SQL statement and the database tables.

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: java.sql.SQLException: Column not found.
PROBABLE CAUSES: The method ResultSet.getXxx(columnName) cannot locate 
   the requested columnName in the ResultSet.
POSSIBLE SOLUTION: Make sure that the column is included in the SELECT statement, 
   so that it is included in the ResultSet.

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: 
  [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
  [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
  ....
PROBABLE CAUSES: Syntax error in the SQL statement.
POSSIBLE SOLUTION: Obvious!

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: 
  [Microsoft][ODBC Microsoft Access Driver] SQL General Error.
PROBABLE CAUSES: This message is not clear, but most likely caused by inserting a record
  with duplicate primary key.

SYMPTOM (Access 2007): Can compile the JDBC program but Runtime Error
ERROR MESSAGE: 
  [Microsoft][ODBC Microsoft Access Driver] The number of fields are not the same as the ....
PROBABLE CAUSES: In the INSERT INTO tableName VALUES (...), you should have the same number
  of values as the number of columns.

NetBeans Common Errors

SYMPTOM: Cannot display chinese characters and other Unicode characters in the NetBeans editor
ERROR MESSAGE: Chinese characters displayed as boxes or question marks in the NetBeans editor
CAUSES/SOLUTION:
  1. Check the character set. Right-click on the project ⇒ Property ⇒ "Source" node 
     ⇒ "Encoding" ⇒ Choose "UTF-8" or the desired Unicode character sets.
  2. You also need to choose a font type that displays chinese or Unicode characters,
     such as "Monospace".
     In "Tools" menu ⇒ Options ⇒ Fonts & Colors ⇒ Syntax ⇒ default.
     If one font does not work, try another.

C++ with GCC Compiler

SYMPTOM: Cannot compile
ERROR MESSAGE: error: 'string' does not name a type
CAUSES/SOLUTION: missing "using namespace std;"
 
SYMPTOM: Cannot compile
ERROR MESSAGE: error: iostream: No such file or directory
CAUSES/SOLUTION: The file is incorrectly saved as ".c" instead of ".cpp"