Skip to content

Instantly share code, notes, and snippets.

@fujohnwang
Created July 10, 2012 07:29
Show Gist options
  • Save fujohnwang/3081819 to your computer and use it in GitHub Desktop.
Save fujohnwang/3081819 to your computer and use it in GitHub Desktop.
hack mysql jdbc driver to send raw command
Class.forName("com.mysql.jdbc.Driver")
val connection = DriverManager.getConnection("jdbc:mysql://10.20.142.140/", "darren", "")
try {
val command = ComBinlogDump("mysql-bin.000001", 4L, 111)
val buffer = connection.asInstanceOf[JDBC4Connection].getIO.sendCommand(MysqlDefs.COM_BINLOG_DUMP, null, command.toMysqlBuffer(), false, null, 0)
println("buffer.getPosition=" + buffer.getPosition)
println("buffer.getBufLength=" + buffer.getBufLength)
println(buffer.dump())
} finally {
connection.close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment