krummas / DrizzleJDBC

A BSD licensed JDBC driver for Drizzle and MySQL
BSD 3-Clause "New" or "Revised" License
31 stars 22 forks source link

Driver badly react to "too many connections" error #44

Open gilius38 opened 6 years ago

gilius38 commented 6 years ago

When connecting to a MySQL server that has reached too many connections, you'll get a ugly BufferUnderflowException:

java.nio.BufferUnderflowException at java.nio.Buffer.nextGetIndex(Buffer.java:498) at java.nio.HeapByteBuffer.getInt(HeapByteBuffer.java:355) at org.drizzle.jdbc.internal.common.packet.buffer.Reader.readInt(Reader.java:80) at org.drizzle.jdbc.internal.mysql.packet.MySQLGreetingReadPacket.<init>(MySQLGreetingReadPacket.java:54) at org.drizzle.jdbc.internal.mysql.MySQLProtocol.<init>(MySQLProtocol.java:155) at org.drizzle.jdbc.DrizzleDriver.connect(DrizzleDriver.java:89)

Looking at the code, greeting packet reading doesn't handle the case where an error packet is sent by the server in place of the greeting packet