More APIs Become Available
3. More APIs Become Available:
Some APIs and new methods have been added in JDBC
6.0.
More APIs have been added to this version of JDBC to provide access to
commonly implemented features of SQL:2003. In addition, several new methods have
been added to commonly used interfaces to support easier and better data
manipulation.
Now, let's review some working code and discuss the result
of the Example1 class below. It will connect to an embedded Apache Derby
database and display the query results in the console. Although JDBC 4.0 has
been out for several months now, I found Apache Derby is the only database to
provide a driver that even partially supports the JDBC 4.0 specification at the
time of this writing (March 2007). All examples in this article are developed
using JDK 1.6 and Apache Derby database version 10.2.2.0. For all code examples,
I will show only snippets of the actual Java source file that are relevant to
the discussion. See the Resources section for complete sample code discussed in
this article.
EXAMPLE:
4. Changes in Connection and Statement Interface:
Some new features have been added to the Connection interface.
However, first of all lets see the methods which are already in use to check whether
a Connection object is still valid/active or not.
int tenSeconds = 10;
Connection.isValid(tenSeconds);
In the above code the argument that specifies the time
duration taken by the API to check whether the Connection is valid or not is
Connection.isValid(int) that is Connection.isValid(tenSeconds);.
This argument is the Timeout value. The value false will be returned if the timeout interval
exceeds. And if the value returned is 0 for the time-out interval that indicates an Infinite Time-out Duration.
Moreover the methods which are used for populating and retrieving the Client Information
about a particular driver are:
Connection.getClientInfo()
Connection.setClientInfo(Properties) methods
also the methods which are used to retrieve the Client information individually
are:
Connection.setClientInfo(String,String)
Connection.getClientInfo(String)
Now lets see the methods which have been added to
the Statement interface.
- Statement.isClosed() - If the Statement Object is closed
it will return true by calling the Statement.close() method.
- Statement.setPoolable(boolean) - The call to
Statement.setPoolable(true) will only act as a request to the Implementation to pool this Statement Object for better performance.
- Statement.isPoolable() - By default, only
PreparedStatement and CallableStatement are pooled by the Implementation. Not all the implementations may support this feature and hence Applications should not depend on this feature always.
|
Current Comments
3 comments so far (post your own) View All Comments Latest 10 Comments:<%@ page contentType ="text/html" language ="java"%>
<%@ taglib uri ="http://java.sun.com/jstl/core" prefix ="c"%>
<html>
<head>
<h1><i><center>Candidates INFO</center></i></h1>
</head>
<body >
<font size="6" face="Times" text size="25">
<form action="">
<b>
Name:                      
<input type="text" name="name" size = "25">
<br>
Mobile No:              
<input type="number" name="mobileNumber" size = "25">
<br>
Contact No:             
<input type="number" name="contactNumber" size = "25">
<br>
Email Address:       
<input type="text" name="emailAddress" size = "25">
<br>
Contact Address:<br>
                           
       <textarea rows="10" cols="25" name="contactAddress"></textarea>
<br>
College:
                   
<input type="text" name="college" size="25">
<br>
Qualification:
         
<select name="qualification" >
<option value="B.E.,">B.E.,</option>
<option value="M.C.A">M.C.A</option>
<option value="B.Sc">B.Sc</option>
<option value="M.Sc">M.Sc</option>
</select>
           
Others:
<input type="text" name="others" size="25">
<br>
Year Of Passing:
     
<select name="yearOfPassing" >
<c:forEach var ="i" begin ="1975" end ="2009" varStatus ="j">
<option value ="${i}">${i}</option>
</c:forEach>
</select>
<br>
Percentage:
             
<select name="percentage" >
<c:forEach var="i" begin="55" end="99" varStatus="j">
<option value="${i}">${i}</option>
</c:forEach>
</select>
<br>
Department:
           
<select name="department">
<option value="CSE">CSE</option>
<option value="IT">IT</option>
<option value="ECE">ECE</option>
<option value="EEE">EEE</option>
<option value="E&I">E&I</option>
<option value="MECH">MECH</option>
<option value="CIVIL">CIVIL</option>
<option value="CHEMICAL">CHEMICAL</option>
</select>
<br>
Sex:
                           
<select name="sex" >
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<br>
Date Of Birth:
         
<select name="date" >
<c:forEach var="i" begin="1" end="31">
<option value="${i}">${i}</option>
</c:forEach>
</select>
<select name="month" >
<c:forEach var="i" begin="1" end="12">
<option value="${i}">${i}</option>
</c:forEach>
</select>
<select name="year" >
<c:forEach var="i" begin="1960" end="2009">
<option value="${i}">${i}</option>
</c:forEach>
</select>
<br>
Prior Experience:
   
<select name="priorExperience" >
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>               
Years Of Experience:
<select name="yearsOfExperience">
<c:forEach var="i" begin="1" end="15">
<option value="${i}">${i}</option>
</c:forEach>
</select>
<br>
Skill Set:                 
<font size=3>
1.<input type="text" name="skillSet1" size="25"><br>
                                                                   
2.<input type="text" name="skillSet2" size="25"><br>
                                                                   
3.<input type="text" name="skillSet3" size="25"><br>
                                                                   
4.<input type="text" name="skillSet4" size="25"><br>
                                                                   
5.<input type="text" name="skillSet5" size="25"><br>
                                                                   
6.<input type="text" name="skillSet6" size="25"><br>
</font size>
Fathers Name:         
<input type="text" name="fathersName" size="25">
<br>
Martial Status:         
<select name="martialStatus">
<option value="Married">Married</option>
<option value="Unmarried">Unmarried</option>
</select>
<br>
ExtraCurricular<br> Activities:                   
<select name="extraCurricularActivity">
<c:forEach var = "i" begin ="1" end ="10">
<option value= "${i}">${i}</option>
</c:forEach>
</select>
<center>
<input type="button" value="Submit" >
<input type="button" value="Cancel">
</center>
</b>
</font>
</form>
</script>
</body>
</html>
Posted by nithu on Saturday, 01.19.08 @ 11:20am | #45574
Connection.setClientInfo(Properties) methods
Posted by Connection.setClientInfo(Properties) methods on Friday, 01.11.08 @ 13:06pm | #44967
Connection.setClientInfo(Properties) methods
Posted by Connection.setClientInfo(Properties) methods on Friday, 01.11.08 @ 13:05pm | #44966