Reputation: 545
What is the difference between javax.sql and java.sql I understand that javax.sql is for JavaEE. or am I wrong.
I am struggling with understanding this difference. And their usage scenarios.
Upvotes: 17
Views: 14631
Reputation: 719089
What is the difference between
javax.sql
andjava.sql
I understand thatjavax.sql
is for JavaEE.
It used to be that javax.sql
was for JDBC extensions that were in Java EE and not Java SE, but this changed as of JDBC 3.
Now both packages are part of JDBC in Java SE, and the fact that there are two packages is now just a historical anomaly. The two packages continue to exist because removing one would cause backwards compatibility problems.
And their usage scenarios.
You basically use whichever package provides the part of the JDBC API that you need. Or more likely, you use both of them. Relevant scenarios can be deduced from the JDBC documentation and the javadocs.
Upvotes: 27
Reputation: 1
java.sql Interface Connection public interface Connection extends WrapperWrapper A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection. A Connection object's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information is obtained with the getMetaData method.
Connection property inspector getCatalog StringString getCatalog() throws SQLExceptionSQLException Retrieves this Connection object's current catalog name. Returns: the current catalog name or null if there is none Throws: SQLExceptionSQLException - if a database access error occurs or this method is called on a closed connection
Upvotes: -1
Reputation: 34
java.sql.* --> This package is used for the basic JDBC connections.
javax.sql.* --> This package provides advance JDBC features such as connection pooling, distributed transaction, disconnected row sets
Upvotes: -1
Reputation: 122008
Provides the API for accessing and processing data stored in a data source (usually a relational database) using the JavaTM programming language.
. This API includes a framework whereby different drivers can be installed dynamically to access different data sources. Although the JDBCTM API is mainly geared to passing SQL statements to a database, it provides for reading and writing data from any data source with a tabular format. The reader/writer facility, available through the javax.sql.RowSet group of interfaces, can be customized to use and update data from a spread sheet, flat file, or any other tabular data source.
Provides the API for server side data source access and processing from the JavaTM programming language. This package supplements the java.sql package and, as of the version 1.4 release, is included in the Java Platform, Standard Edition (Java SETM). It remains an essential part of the Java Platform, Enterprise Edition (Java EETM).
Upvotes: 2