Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Object RunQuery(String query) throws Exception{
- System.out.println("Trying to run query");
- Statement stmt = null;
- ResultSet rs = null;
- try {
- stmt = conn.createStatement();
- System.out.println("Got Statement");
- rs = stmt.executeQuery(query);
- System.out.println("Query executed");
- ...
- } catch (SQLException ex) {
- // handle any errors
- System.out.println("SQLException: " + ex.getMessage());
- System.out.println("SQLState: " + ex.getSQLState());
- System.out.println("VendorError: " + ex.getErrorCode());
- }
- catch (Exception ex) {
- System.out.println("Exception: " + ex.getMessage());
- }
- finally {
- if (rs != null) {
- try {
- rs.close();
- } catch (SQLException sqlEx) {
- } // ignore
- rs = null;
- }
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException sqlEx) {
- } // ignore
- stmt = null;
- }
- return ret;
- }
- }
- query = "SELECT * FROM smalltable"
- query = "SELECT * FROM bigtable"
- >Exception occurred in target VM: Communications link failure Last packet sent to the server was 0 ms ago.
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Last packet sent to the server was 0 ms ago.
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
- at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
- at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
- at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
- at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3009)
- at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2895)
- at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3438)
- at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
- at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
- at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)
- at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2477)
- at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1422)
- at RunQuery
- Caused by: java.net.SocketException: Software caused connection abort: recv failed
- at java.net.SocketInputStream.socketRead0(Native Method)
- at java.net.SocketInputStream.read(SocketInputStream.java:129)
- at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:157)
- at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
- at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2452)
- at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2962)
- ... 9 more
- jdbc:mysql://localhost?user=root&password=password
Add Comment
Please, Sign In to add comment