What is a mysql driver in java?

1

Could someone explain to me what exactly is a driver and what would be using it with mysql?

It's been a while since I started watching JBDC videos and the word "Drivers" is constantly being used, and with Google's response, it's not enough for me to understand how it links to mysql.

This is a sample code that is what I learned so far with mysql in java.

try {
            //1. Conectarse a la base de datos.
            Connection coneccion = DriverManager.getConnection("jdbc:mysql://localhost:8889/Java", "root", "root");

            //2.Crear el statement.
            Statement statement = coneccion.createStatement();

            //3.Generar una consulta.
            ResultSet resultado = statement.executeQuery("SELECT * FROM Productos");

            //4.Leer el resulset.       
            while ( resultado.next() ) {

                String idArt = resultado.getString(1);
                String seccionArt = resultado.getString(2);
                String nombreArt = resultado.getString(3);

                System.out.println("ID: " + idArt + ". Seccion: " + seccionArt + ". Nombre: " + nombreArt );

            }
    
asked by MatiEzelQ 01.04.2016 в 18:22
source

1 answer

3

In terms of Java and JDBC, it is called the jar or library driver that allows communication with a particular database engine. It happens that JDBC is an interface framework that provides Java to communicate with any database engine, what the database engine provider (or the community) is to provide an implementation of this group of interfaces to allow access and communication to the database engine in question.

In your case, you are using a driver to connect to MySQL, you can use the official driver (jar) that mysql provides on its download page.

In the same way, to communicate with another database server, you must use the appropriate driver (jar). For example, to communicate with a SQL Server database there are two options: 1) the Microsoft official driver (jar) and 2) a driver (jar) called jTDS that is maintained by the community, each one has its pros and cons and the choice of one or the other will depend on those particular needs.

    
answered by 01.04.2016 / 19:02
source