PDA

Click to See Complete Forum and Search --> : [RESOLVED] difference between java.sql and javax.sql


vb_student
Nov 11th, 2006, 06:01 PM
hello

i was wondering what the difference between the java.sql and javax.sql libraries were?

CornedBee
Nov 11th, 2006, 06:36 PM
They contain different stuff. The javax.sql stuff contains a few extensions to the core JDBC in java.sql, like the DataSource interface.

vb_student
Nov 11th, 2006, 06:59 PM
thanks for the reply cornedbee

is java.sql a subset of javax.sql?

CornedBee
Nov 11th, 2006, 07:13 PM
No. javax.sql is an extension to java.sql. It contains additional classes and interfaces. But they still are based on the functionality provided by java.sql.

For example, javax.sql.DataSource is a method of obtaining java.sql.Connection objects.

vb_student
Nov 12th, 2006, 07:08 AM
thanks for yet another insight cornedbee

but why could they not release a new version of java.sql, why add a new library?

i guess when you import javax.sql, one does not need to import java.sql?

CornedBee
Nov 12th, 2006, 08:21 AM
i guess when you import javax.sql, one does not need to import java.sql?
And why would you assume that? They're just Java packages. They have no idea that they're related.
(You shouldn't import complete packages either, just single classes selectively.)

but why could they not release a new version of java.sql, why add a new library?
The javax.sql stuff was originally part of the J2EE specification, which never modifies java.* packages, only javax.* packages. Thus they couldn't alter java.sql.
When in J2SE 1.4 they included the new stuff, they didn't want to change the package name, obviously: it would have broken both source and binary compatibility.

vb_student
Nov 12th, 2006, 09:08 AM
i thought

import java.sql.*


imported the whole package, how does one import just a class?

so java.* package are the foundation packages, and javax.* packages are the packages built on java.*

does java add on javax.* or does it modify javax.*

by changing/modifying the javax.* packages isn't source and binary compatibility broken?

CornedBee
Nov 12th, 2006, 09:37 AM
imported the whole package, how does one import just a class?
import java.sql.Connection;

so java.* package are the foundation packages, and javax.* packages are the packages built on java.*
Sort of. Not all javax.* classes are built on the java.* classes; instead they provide completely independent services. javax contains Swing, for example.

Does java add on javax.* or does it modify javax.*
Eh?
Look, forget "modifying" and "adding". They're all just classes. They may make use of classes in other namespaces, but nothing modifies anything else.

by changing/modifying the javax.* packages isn't source and binary compatibility broken?
Sure, but these packages weren't changed. Adding new classes to a package doesn't break anything (except source that uses wildcard imports like "import java.util.*" - that can break if a new symbol conflicts with another that's in scope), nor does adding new methods to classes break anything. Only modifying existing things breaks code: changing the package a class is in, for example.

vb_student
Nov 17th, 2006, 04:43 PM
thanks for the insight cornedbee