Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is the current version of JDBC? and explain its
features?

Answers were Sorted based on User's Feedback



what is the current version of JDBC? and explain its features?..

Answer / koundinya_1993

JDBC 4.0,
Some of the new set of features which come along with
Mustang is JDBC 4.0 are:

No need for Class.forName("DriverName")

Changes in Connection and Statement Interface

Better Pools

Using ResultSet Becomes More Flexible

More APIs Become Available

Is This Answer Correct ?    6 Yes 1 No

what is the current version of JDBC? and explain its features?..

Answer / dinesh

The current version of JDBC is JDBC 4:
1.SQL 2003support.
2.XML as a First-Class SQL Data Type.
3.Using JDBC 4's SQLXML data type, you could retrieve a
user's blog.
4.Exceptional exceptions:
5,Type-safe querying and results:


In details about above one:
1.SQL 2003support
Connection c = myDataSource.getConnection();
PreparedStatement st = c.prepareStatement("insert into
siteusers (userid, username) values
(?, ?);
st.setRowId(1, rowId1);

When creating a new BLOB or CLOB object through
Connection's appropriate create() method,

the resulting object does not contain the actual binary or
character data. Rather, you would add

the "real" data to the CLOB or BLOB objects:

Connection c = myDataSource.getConnection();
Blob myBlob = c.createBlob();
OutputStream outStream = myBlob.setBinaryStream(0);

2.XML as a First-Class SQL Data Type
create table user_has_blog(userid int, blog_entry xml);

3.Using JDBC 4's SQLXML data type, you could retrieve a
user's blog entries as follows:
Connection c = myDataSource.getConnection();
PreparedStatement st = c.prepareStatement("select userid,
blog_entry from user_has_blog");
ResultSet rs = st.executeQuery();
while (rs.next()) {
SQLXML blog = st.getSQLXML("blog_entry");
javax.xml.stream.XMLStreamReader reader =
blog.createXMLStreamReader();
blog.free();
}

SQLXML's createXMLStreamReader() returns a StAX stream
reader, which is a low-level interface

allowing access to an XML stream . See the reference at
the end of this article about using StAX

to read and write XML data. Whenever you've exhausted the
XML stream, you need to invoke

close() on SQLXML to free resources associated with the XML
data stream.

.The following SQL selects all users with their first and
last names into XML User elements:
create table user (int userid, firstname varchar(128),
lastname varchar(128))
select e.userid,
XMLELEMENT(NAME
"user", e.firstname || e.lastname) as "result" from
employee e;


Creating and inserting into the database a new SQLXML value
is similar to working with BLOBs.

You invoke Connection's createSQLXML() method, and then
populate the resulting SQLXML's

input stream with the XML content:

Connection c = myDataSource.getConnection();
PreparedStatement st = c.prepareStatement("insert into
user_has_blog (userid, blog_entry)

values (?, ?)");
SQLXML blogEntry = c.createSQLXML();
Writer writer = blogEntry.createXMLSteamWriter();
//write XML content to writer
st.setInt(1, 1); //User id
st.setSQLXML(2, blogEntry)


4.Exceptional exceptions:
In JDBC4:SQL Exception has getNextException() and getCasuse
() methods
The method getNextException() :returns either the next
Exception in the exception chain, or null,

when the root of the hierarchy is reached.
The method getCasuse() : return a non-SQLException subtype
SQLTransientException :SQLTransientConnectionException,SQLTi
meoutException

,SQLTransactionRollbackException

SQLNonTransientException:SQLDataException

,SQLIntegrityConstraintViolationException,SQLInvalidAuthoriz
ationSpecException

,SQLNonTransientConnectionException ,SQLSyntaxErrorException


5,Type-safe querying and results:
Consider the class
class User {
int userID;
String name;
String department;
}


Consider the Table:
create table user (int userid, name varchar(128),
department varchar(128));

Template Class
class MyQueries {
public static final String SELECT_ALL_USERS
= "select * from user";
}


interface MyQueries extends BaseQuery {

@Query(sql="select * from user")
DataSet getAllUsers();
}

You are obtain an instance of MyQuery from the Connection
class:
DataSource myDataSource = new DataSource();
Connection c = myDataSource.getConnection();
MyQueries myQueries = c.createQueryObject(MyQuery.class);
DataSet users = myQueries.getAllUsers();
for (User u: users) {
System.out.println("User's name is: " + user.name;
}

//For ex getting dep details
interface MyQueries extends BaseQuery {

@Query(sql="select * from user where department=
{department}")
DataSet getDepartmentUsers(String department);
}

//For update query
interface MyQueries extends BaseQuery {

@Update(sql="update user set department={deparment}
where name= {userName}")
int updateDeparment(String userName, String
department);
}
Dataset allows you to insert and update data in the
database.
Connection c = myDataSource.getConnection();
MyQueries q = c.createQueryObject(MyQueries.class);
DataSet users = q.create();
User user = new User();
user.setUserID(1);
user.setName("Joe");
user.setDeparment("Accounting");
users.insert(user);


This are the advantage in JDBC 4 new version.

Is This Answer Correct ?    3 Yes 1 No

what is the current version of JDBC? and explain its features?..

Answer / naresh katakam

JDBC 6.0

features:
No need for Class.forName("DriverName")


The three most important features of Driver and Connection
Management in JDBC are described below with some new
features and enhancements.

1. Getting Connected Becomes Easier


Using ResultSet Becomes More Flexible
More APIs Become Available:

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More JDBC Interview Questions

What do you mean by metadata and why we are using it?

0 Answers  


What is JDBC?

3 Answers   Akamai Technologies,


How MS-Access DB can be accessed over a network, using JDBC API?

0 Answers  


What is an outer join?

3 Answers   Infogain,


What are the Isolation level in JDBC transaction?

1 Answers  


any one can explain about policy file rule? when i connect database with applet then ther is no compile time error but the run time error is occureed.i.e access is denied.policy file rule is related to this problem.

0 Answers  


Is jdbc part of j2ee?

0 Answers  


What is the JDBC syntax for using a literal or variable in a standard Statement?

0 Answers  


Diff bet.. Function and Trigger?

3 Answers   Logica CMG,


What is meant by jdbc and odbc?

0 Answers  


What are the steps involved in establishing a connection using jdbc in java?

0 Answers  


What are the types of jdbc drivers that exist?

0 Answers  


Categories