I've only learned Java last quarter of 2010. I can say the knowledge I gained as of now are not enough and there's a lot of improvement. I still do studying while developing but most of my code is snippet from other current working application. I guess my way of studying the language affect the way I know it. Instead of learning the basic first, I jump up to advanced features that affect how I understand it. (I did advanced to fulfill my previous project tasks.)
I often connect to my MySql database using import java.sql.connection
etc. I'm using Eclipse IDE then when I create an instance of Connection/PreparedStatement and I haven't imported the packages. Eclipse will show related Packages that's where mysql.jdbc.*
I've encountered.
All though I did some research about it still its not too clear for me. The difference of those to packages.
I know someone here can enlighten me more about this.
JDBC requires separate get and/or set call statements for each bind variable and specifies the binding by position number. SQLJ provides strong typing of query outputs and return parameters and allows type-checking on calls. JDBC passes values to and from SQL without compile-time type checking.
In Java, we can connect to our database(MySQL) with JDBC(Java Database Connectivity) through the Java code. JDBC is one of the standard APIs for database connectivity, using it we can easily run our query, statement, and also fetch data from the database.
JDBC is a Java API for connecting to various types of RDBMS. API stands for "application programming interface." JDBC is definitely one of these, and so is HBase.
JDBC is an adapter layer from Java to SQL: it gives Java developers a common interface for connecting to a database, issuing queries and commands, and managing responses.
To quote from the javadoc for com.mysql.jdbc.Connection:
This interface contains methods that are considered the "vendor extension" to the JDBC API for MySQL's implementation of java.sql.Connection.
So, that class at least builds on top of JDBC to add more features. But it's still JDBC at heart - you're using this class when you use pure JDBC, you just don't see it.
I would say that if you can build your app using only the standard JDBC interfaces, do so. If you absolutely need MySQL-specific API features, then use the MySQL interfaces. I work with Oracle mostly, and in all the years i've been doing it, i've never had to fall back to any Oracle-specific interfaces; there's a huge amount you can do with JDBC.
To address your points:
To put it simply: Java (J2SE/J2EE) provides java.sql.* as the standard way to connect to a database. The issue is that these classes do not know really know how to connect to each specific database in the model, they are oriented to the programmer.
To connecto to each database, you need to put in its Driver. The Oracle driver will know how to connect to the Oracle database, the mysql driver will know how to connect to MySQL. java.sql. will know how to use each Driver, so by just using it you do not need to know the internals of each Driver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With