Re: com.mysql.jdbc.UpdatableResultSet.updateBlob gives AbstractMethodError



Lew wrote:
pjvleeuwen@xxxxxxxxx wrote:
public static void main(String[] args)
throws MalformedURLException,
IOException, SQLException {
...
// write to DB
Connection con = null;
try {
Class
.forName(
"com.mysql.jdbc.Driver")
.newInstance();

Why are you creating a throwaway instance here?

That is a common practice when loading the MySQL JDBC
driver.

My guess is that some very old version of the driver
registered itself with DriverManager in the constructor,
so that it was necessary.

It is not necessary today and has not been for many years,
but you will see that code all the time.

The MySQL docs even use it even though they blame Java:

<quote>
Example 3.1. Registering the Driver With the DriverManager

The following section of Java code shows how you might register MySQL Connector/J from the main() method of your application.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

// Notice, do not import com.mysql.jdbc.*
// or you will have problems!

public class LoadDriver {
public static void main(String[] args) {
try {
// The newInstance() call is a work around for some
// broken Java implementations

Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
// handle the error
}
</quote>

Arne
.



Relevant Pages

  • RE: Registering the JDBC Driver
    ... Subject: Registering the JDBC Driver ... ODBC connection to the database.However the Application is written in JAVA ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: Java / SQL Server 2005
    ... No suitable driver ... an SQL database - all with identical results. ... Connection con = DriverManager.getConnection; ... use Microsofts JDBC driver for SQLServer 2005. ...
    (comp.lang.java.programmer)
  • Re: Java / SQL Server 2005
    ... No suitable driver ... an SQL database - all with identical results. ... Connection con = DriverManager.getConnection; ... use Microsofts JDBC driver for SQLServer 2005. ...
    (comp.lang.java.programmer)
  • Re: JDBC to Ingres Woessss....
    ... > that should be connecting to my ingres database but I can't even get ... > that the driver is in a jar file in the ingres directory. ... > the program it just says it failed to load the driver. ... Connection con = DriverManager.getConnection; ...
    (comp.lang.java.databases)
  • kernel error
    ... but USB mouse is detected ... card driver dont work correctly) ... Failure registering Root Plug module with the kernel ... PCI: MCFG area at f0000000 reserved in E820 ...
    (Linux-Kernel)