tag:blogger.com,1999:blog-7399505615081701422024-02-08T13:13:23.183+05:30Start Learning With MeVINODhttp://www.blogger.com/profile/17567935148510637824noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-739950561508170142.post-54944275295861667452014-03-06T05:52:00.000+05:302014-03-06T06:48:39.309+05:30JDBC ResultSet Interface<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
<span style="font-family: inherit;">ResultSet is an interface in java.sql package which has methods to retrieve and manipulate the results of an executed query. Broadly ResultSet provides the functionalities for navigation, retrieval and update .</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">ResultSet exhibit different characteristics. They can be classified into type, concurrency and cursor hold ability.</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<div style="text-align: justify;">
<strong><span style="font-family: inherit;">1) ResultSet Types:</span></strong></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">The type of ResultSet object can be defined on two aspects the navigation of records and how sensitive the ResultSet is to concurrent changes to the underlying data store.</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">Base on these we have 3 different ResultSet types:</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<ul style="text-align: left;"><div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">TYPE_FORWARD_ONLY : The ResultSet can only be scrolled or navigated in forward direction. This is the default type and is not sensitive to the underlying data store changes.</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></ul>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<ul><div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">TYPE_SCROLL_INSESITIVE: The ResultSet can be scrolled either in forward or backward direction. We can move to absolute location or relative record position using this type of scrolling. However Result set is insensitive or insulated from the underlying data store changes</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></ul>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<ul><div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">TYPE_SCROLL_SENSITIVE: This type is exactly has the same functionality as the TYPE_SCROLL_INSESITIVE in terms of scrolling however the result set is sensitive to the changes in underlying data store.</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></ul>
<div style="text-align: justify;">
<strong><span style="font-family: inherit;">2) RsultSet Concurrency:</span></strong></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">They determine the level of update functionality provided. There on two categories based on this criteria:</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<ul><div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">CONCUR_READ_ONLY : The ResultSet type object cannot be used for updates to data store.</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">CONCUR_UPDATABLE: The ResultSet typeobject can be used for updating the data store.</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></ul>
<div style="text-align: justify;">
<strong><span style="font-family: inherit;">3) Result Set Holdablity :</span></strong></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">By default if we can Connection.commit() after the transaction, the ResultSet object will get closed automatically. This default behavior may not be desired in some business scenarios. JDBC does provide a way to control this through java application. </span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">The following two constants of ResultSet interface can be passed to Connection methods createStatement,prepareStatement and prepareCall to control this behavior of Connection.commit() call:</span></div>
<ul><div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">HOLD_CURSORS_OVER_COMMIT : ResultSet's are not closed on an commit. Instead they are held. These type is very useful if the ResultSet are read only.</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
</div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">CLOSE_CURSORS_AT_COMMIT: ResultSet closed immediately on a commit call. This can produce better performance over the later one.</span></div>
</li>
</ul>
<div style="text-align: justify;">
<strong><span style="font-family: inherit;"></span></strong><br />
<strong><span style="font-family: inherit;">Applying the Above in Coding:</span></strong><br />
<span style="font-family: inherit;"></span><br />
<br />
<span style="font-family: inherit;">
ResultSet can be created by below methods:</span><br />
<br />
1) Using ExecuteQuery() on a Statement type object calling a SELECT query. <br />
<br />
2) The second approach is to get a Statement type object from the Connection object using createStatement() method. After a statement is created we can issue getResultSet() call to get the corresponding ResultSet type object.<br />
<br />
Example1:<br />
Statement st=connection.CreateStatement();<br />
Boolean bVal=st.execute("SELECT * FROM EMP");<br />
ResultSet st=st.getResultSet();<br />
<br />
<br />
The Connection type object provides 3 overloaded createStatement() methods:<br />
<br />
1) Statement createStatement() : This returns a default Statement type object which produces the default ResultSet on calling an executeQuery. The returned ResultSet is ForwardOnly,ReadOnly and cannot hold the result type on transaction commit(). The example [Example1] provided above demonstrates this.<br />
<br />
2) Statement createStatement(<span style="font-family: Courier New;">int resultSetType, int resultSetConcurrency)T</span><span style="font-family: Times New Roman;">his</span><br />
provides flexibility over the plain createStatement() in a way that we can define the ResultType we want after execution of the query.<br />
<br />
Example 2: If we want a scrollable ,sensitive,updatable ResultSet we can call as below:<br />
<span style="font-size: x-small;">st=connection.CreateStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);</span><br />
<span style="font-size: x-small;"></span><br />
Please note that we can do the same for a PrepareStatement or CallableStatement using prepareStatement() or prepareCall() respectively.<br />
<br />
3) Statement createStatement(<span style="font-family: Courier New;">(int resultSetType, int resultSetConcurrency, int resultSetHoldability</span><span style="font-family: inherit;">)</span><br />
<br />
This provides flexibility for even mentioning whether ResultSet is Holdable or not after a commit.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div style="text-align: justify;">
</div>
<ul>
</ul>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
</div>
</div>
VINODhttp://www.blogger.com/profile/17567935148510637824noreply@blogger.com0tag:blogger.com,1999:blog-739950561508170142.post-79615970647790362592014-03-05T05:12:00.001+05:302014-03-05T05:36:42.446+05:30JDBC Sample Java Code to Connect With Oracle<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
In previous blog I covered different interface of java.sql package that are important for writing jdbc code to get connected to the database. In this blog we will study a sample code on how we can get connected to the Oracle data base and execute a sample query to get the Result set and print it on the console.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="font-family: Times, "Times New Roman", serif;">For this purpose we are assuming that oracle is installed on our local system and we have a schema called "<em>vinodoracle</em>" and a password "<em>vinodoracle</em>". We also assume we do have a table with name <span style="background-color: #fff0f0;">EMP with column names "EMPLOYEEID","NAME" and "SALARY" of types NUMBER,VARCHAR2 and NUMBER respectively. </span></span></div>
<span style="font-family: Times, "Times New Roman", serif;"></span><br />
<span style="font-family: Times, "Times New Roman", serif;">The table does look as below :</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSPFLmCtTZ6Aw3J3EQWmQNNqMVZQAF6suUgx94R4c0X1Rs7y1mqCtITlCPl5xVv48aYdCkiFta8pVVvj-20rEoAHVkE8KeWCK_6Tt6cmRg3eoDatlBFgatW29Yk0VzHFMTVrYDosh83RY/s1600/EMP.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSPFLmCtTZ6Aw3J3EQWmQNNqMVZQAF6suUgx94R4c0X1Rs7y1mqCtITlCPl5xVv48aYdCkiFta8pVVvj-20rEoAHVkE8KeWCK_6Tt6cmRg3eoDatlBFgatW29Yk0VzHFMTVrYDosh83RY/s1600/EMP.jpg" /></a></div>
<br />
<div style="text-align: justify;">
<span style="font-family: Times, "Times New Roman", serif;">The comments in the below program are self explanatory.</span></div>
<div style="text-align: justify;">
<span style="font-family: Times, "Times New Roman", serif;"></span><br /></div>
<div style="text-align: justify;">
<span style="font-family: Times, "Times New Roman", serif;">The Line #22 loads the OracleDriver class and initializes the driver. The line #24 supplies the url,uid and pwd and creates a coonection to oracle data base. We assume Oracle is installed on local machine so localhost in our url. Line #27 obtains a statement type object from the connection and Line #29 executes SELECT query and stores the result in ResultSet type object of Oracle. Which can then be printed as we are doing. </span></div>
<div style="text-align: justify;">
<span style="font-family: Times, "Times New Roman", serif;"></span><br /></div>
<div style="text-align: justify;">
<span style="font-family: Times, "Times New Roman", serif;">We are catching ClassNotFoundException for Class.forName("") call. If we don't have oracle supplied Driver jar in our class path we do catch this exception. So make sure we have ojdbc14jar in our class path .</span></div>
<div style="text-align: justify;">
<span style="font-family: Times, "Times New Roman", serif;"></span><br /></div>
<span style="font-family: Times, "Times New Roman", serif;">The url information can be obtained from a file called trans.ora file within oracle installation folder.</span><br />
<span style="font-family: Times;"></span><br />
<span style="font-family: Times;">Please focus on how we are retrieving the values from the record set. RecordSet interface provides methods like getInt, getString etc.. to retrieve the values from the current record set. We can either pass Column Name or Column Number as parameter. In the below code at Line #35 we use Column Name to get the values of EMPLOYEEID and NAME . But we are getting SALARY by using column number as parameter to getNumber . Also note that column numbers are not zero based . They start from one.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<span style="font-family: Times, "Times New Roman", serif;"></span><br /></div>
<span style="font-family: Times, "Times New Roman", serif;"><!-- HTML generated using hilite.me --></span><br />
<div style="background: rgb(255, 255, 255); border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">
<span style="font-family: Times, "Times New Roman", serif;">
</span><br />
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0px;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51</pre>
</td><td><pre style="line-height: 125%; margin: 0px;"><span style="color: #008800; font-weight: bold;">package</span> com<span style="color: #333333;">.</span><span style="color: #0000cc;">vinod</span><span style="color: #333333;">.</span><span style="color: #0000cc;">oracle</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.Connection</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.DriverManager</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.ResultSet</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.SQLException</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.sql.Statement</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">FirstOracleConnection</span>
<span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">main</span><span style="color: #333333;">(</span>String<span style="color: #333333;">[]</span> args<span style="color: #333333;">)</span>
<span style="color: #333333;">{</span>
String url<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"jdbc:oracle:thin:@localhost:1521:XE"</span><span style="color: #333333;">;</span>
String uid<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"ravioracle"</span><span style="color: #333333;">;</span>
String pwd<span style="color: #333333;">=</span><span style="background-color: #fff0f0;">"ravioracle"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">try</span>
<span style="color: #333333;">{</span>
<span style="color: #888888;">//Loading the OracleDriver Class</span>
Class<span style="color: #333333;">.</span><span style="color: #0000cc;">forName</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"oracle.jdbc.driver.OracleDriver"</span><span style="color: #333333;">);</span>
<span style="color: #888888;">//Creating the Connection type object by providing the url , uid and password parameters to DriverManager</span>
Connection con<span style="color: #333333;">=</span>DriverManager<span style="color: #333333;">.</span><span style="color: #0000cc;">getConnection</span><span style="color: #333333;">(</span>url<span style="color: #333333;">,</span> uid<span style="color: #333333;">,</span> pwd<span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Connection Successful"</span><span style="color: #333333;">);</span>
<span style="color: #888888;">//Get a Statement type object from Connection</span>
Statement st<span style="color: #333333;">=</span>con<span style="color: #333333;">.</span><span style="color: #0000cc;">createStatement</span><span style="color: #333333;">();</span>
<span style="color: #888888;">//Execute a query</span>
ResultSet rs<span style="color: #333333;">=</span>st<span style="color: #333333;">.</span><span style="color: #0000cc;">executeQuery</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"SELECT * FROM EMP"</span><span style="color: #333333;">);</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"EMPLOYEEID EMPLOYEENAME SALRAY"</span> <span style="color: #333333;">);</span>
<span style="color: #888888;">// Resord set by default is pointed to a Top-1 location. So we need to move next and then access the first record.</span>
<span style="color: #008800; font-weight: bold;">while</span><span style="color: #333333;">(</span>rs<span style="color: #333333;">.</span><span style="color: #0000cc;">next</span><span style="color: #333333;">())</span>
<span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">""</span><span style="color: #333333;">+</span>rs<span style="color: #333333;">.</span><span style="color: #0000cc;">getInt</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"EMPLOYEEID"</span><span style="color: #333333;">)+</span><span style="background-color: #fff0f0;">"\t "</span><span style="color: #333333;">+</span>rs<span style="color: #333333;">.</span><span style="color: #0000cc;">getString</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"NAME"</span><span style="color: #333333;">)+</span><span style="background-color: #fff0f0;">"\t "</span><span style="color: #333333;">+</span>rs<span style="color: #333333;">.</span><span style="color: #0000cc;">getInt</span><span style="color: #333333;">(</span><span style="color: #0000dd; font-weight: bold;">3</span><span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
rs<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
con<span style="color: #333333;">.</span><span style="color: #0000cc;">close</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">catch</span><span style="color: #333333;">(</span>ClassNotFoundException cnf<span style="color: #333333;">)</span>
<span style="color: #333333;">{</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>SQLException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// TODO Auto-generated catch block</span>
e<span style="color: #333333;">.</span><span style="color: #0000cc;">printStackTrace</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
</pre>
</td></tr>
</tbody></table>
</div>
</div>
VINODhttp://www.blogger.com/profile/17567935148510637824noreply@blogger.com0tag:blogger.com,1999:blog-739950561508170142.post-9682272693232302352014-03-03T16:12:00.003+05:302014-03-03T17:07:05.121+05:30 JDBC Coding Steps<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: center;">
<span style="font-family: inherit;">
</span><span style="font-family: inherit;"> </span></h2>
<div style="text-align: justify;">
<span style="font-family: inherit;">Following are different steps involved in a Java Program using JDBC to perform Database operations:</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"> </span></div>
<ul style="text-align: left;"><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">Load the Driver Class</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">Create a Connection to the Data Base providing the necessary privileges and arguments.</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">Get the Statement type Object from the Connection</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">Execute the Data Base Query on the Statement type object obtained.</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span>
<li><div style="text-align: justify;">
<span style="font-family: inherit;">Get the Result Set from the query executed. Process the records</span></div>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span></li>
<span style="font-family: inherit;">
</span><div style="text-align: justify;">
<span style="font-family: inherit;">
</span></div>
<span style="font-family: inherit;">
</span></ul>
<div style="text-align: justify;">
<span style="font-family: inherit;">Now we shall see each step with JDBC coding point of view to connect with Oracle data base.</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">Please note the interfaces from Java [ provided in java.sql and javax.sql remain the same independent of the Data Base server we use. However the parameters we pass to load the vendor specific implementation will change].</span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"> </span></div>
<h3 style="text-align: left;">
<span style="font-family: inherit;">
Loading the Driver Class:</span></h3>
<div style="text-align: left;">
<strong><span style="font-family: inherit;"></span></strong><br /></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">JDBC suggests us to use reflection to load the driver class of specific DB vendor. Internally the Driver class would implement some static block executing initializing the Driver when we do load the class. The general syntax is as follows:</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: justify;">
<em><span style="color: #274e13; font-family: inherit;">Class.forName("<<driverpackage.Driverclass>>");</span></em></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">For loading Oracle database we need to do:</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: justify;">
<em><span style="color: #38761d; font-family: inherit;">Class.forName("oracle.jdbc.driver.OracleDriver");</span></em></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">where oracle.jdbc.driver.OracleDriver is the DriverClass provided by Oracle following JDBC specifications.</span></div>
<div style="text-align: justify;">
<strong><span style="font-family: inherit;"></span></strong><br /></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">Please make sure the jar that has OracleDriver class which comes with oracle installation should be in our class path. </span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<h3 style="text-align: left;">
<span style="font-family: inherit;">
Creating Connection :</span></h3>
<div style="text-align: left;">
<strong><span style="font-family: inherit;"></span></strong><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;">After loading the DriverClass we need to establish connection to the database server. To do this we get a Connection type object of DriverManager. The general syntax is:</span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<em><span style="color: #38761d; font-family: inherit;">Connection con=DriverManager.getConnection(url,uid,pwd);</span></em></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;">Where url specifies the url specified by Database vendor to connect to the DataBase Server. uid is the userId and pwd is the password .</span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;">Example:</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"> To get Connection to Oracle DataBase server running on the localHost:1521 an instance XE and schema (user) admin and password 123 we get Connection as follows:</span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<em><span style="font-family: inherit;">Connection con=DriverManager.getConnection("jdbc:oracle:thin@localhost:1521:XE","admin","123");</span></em></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<h3 style="text-align: left;">
<span style="font-family: inherit;">
Get Statement type Object:</span></h3>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;">We need a Statement type object from the Connection type to interface and communicate with the database. Following is the syntax how we get a Statement type from the Connection. </span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<em><span style="color: #38761d; font-family: inherit;">Statement st= con.createStatement();</span></em></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<h3 style="text-align: left;">
<span style="font-family: inherit;">
Execute the Query :</span></h3>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;">Once we have the Statement we can use execute(),executeQuery() etc.. to send queries to the DataBase.</span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;">Example:</span></div>
<div style="text-align: left;">
<em><span style="color: #38761d; font-family: inherit;">ResultSet rs=st.executeQuery("SELECT * FROM EMPLOYEE");</span></em></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">Now with the the user can develop business specific code to handle the data got from the database in the above case ResultSet rs can be used to manipulate and write business specific .</span></div>
<div style="text-align: justify;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: justify;">
<span style="font-family: inherit;">The thing to note here is Connection,Statement and Result set are the interfaces defined by JDBC standard which all the DB vendors need to implement in order for java to support them.</span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;"></span><br /></div>
<div style="text-align: left;">
<span style="font-family: inherit;"> </span></div>
<div style="text-align: left;">
<span style="font-family: inherit;"> </span></div>
</div>
VINODhttp://www.blogger.com/profile/17567935148510637824noreply@blogger.com0tag:blogger.com,1999:blog-739950561508170142.post-15649528847550283252014-03-03T11:36:00.000+05:302014-03-03T11:37:17.158+05:30JDBC Introduction<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div align="center" class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: "Times New Roman","serif"; font-size: 16pt; line-height: 115%;">JDBC:<o:p></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">Introduction:<o:p></o:p></span></b></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">JDBC provides set of standard Java API’s for
connecting and performing transactions with RDBMS. Thus provides flexibility to
java developers from switching to different data bases in the project life cycle
without much effort.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKZPnJkOMDuloqhHgFAfwdbzuX25zgFPeC0KUMYOCNTbUly_Qeoz_0BTv-vlNoumSI_ytQ7F0QPLWn-2b2cp1rZM5oTLuVQTvj1oE0fRjoJ7pqCGlYAlxduRmxgoyOWiegEsC9U26lUVk/s1600/jdbc.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKZPnJkOMDuloqhHgFAfwdbzuX25zgFPeC0KUMYOCNTbUly_Qeoz_0BTv-vlNoumSI_ytQ7F0QPLWn-2b2cp1rZM5oTLuVQTvj1oE0fRjoJ7pqCGlYAlxduRmxgoyOWiegEsC9U26lUVk/s1600/jdbc.jpg" height="77" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.blogger.com/" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://www.blogger.com/" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><br /></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><o:p></o:p></span> </div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<a href="https://www.blogger.com/" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">Components
of JDBC:<o:p></o:p></span></b></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">Following are key components of JDBC<o:p></o:p></span></div>
<br />
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<!--[if !supportLists]--><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">1)<span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span></b><!--[endif]--><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">JDBC
Driver:<o:p></o:p></span></b></div>
<br />
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in; text-align: justify;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">JDBC
Driver provides set of concrete classes that implement the interfaces defined
by the JDBC API to interact with RDBMS. Each RDMS vendors have to implement
certain interfaces defined by JDBC, thus each vendor comes up with his own JDBC
driver implementation. For example MYSQL gives us their implementation of JDBC
drivers and oracle comes up with its own implementation of the drivers. Thus
this coding for interfaces provides the flexibility of changing the RDMS on the
fly without much effort.<o:p></o:p></span></div>
<br />
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -0.25in;">
<!--[if !supportLists]--><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">2)<span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";"> </span></span></span></b><!--[endif]--><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">Connections:<o:p></o:p></span></b></div>
<br />
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; text-align: justify;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">After
the JDBC driver is loaded, the next step is to make connection to Database server.
We can do this by obtaining the connection object of the JDBC API.<o:p></o:p></span></div>
<br />
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -0.25in;">
<!--[if !supportLists]--><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%; mso-fareast-font-family: "Times New Roman";"><span style="mso-list: Ignore;">3)<span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";"> </span></span></span></b><!--[endif]--><b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">Result Set:<o:p></o:p></span></b></div>
<br />
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in; text-align: justify;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">Once
we do a Read operation or a SELECT query on the RDBMS we get the result set
containing the set of records for a particular query.</span></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><br />
</span><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><o:p><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">Although there are
about 4 different types of Drivers named Tyep1, Type, Type3 and Type4, we
generally deal with type 4 drivers which is a pure java implemented drivers.
The Sun Oracle defines certain interfaces and all the different data base
vendors have to implement this <o:p></o:p></span><br />
<br />
</o:p></span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt; text-align: justify;">
<div class="MsoNormal" style="margin: 0in 0in 10pt; text-align: justify;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">standard imposed by SUN
through these interfaces. This provides more flexibility as the data base can
be changed without any / much changes to the source code and also the
performance is much better compared to other Driver types. No need to mention
that being a pure java implementation this makes the DB application platform
independent.<o:p></o:p></span></span></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">
</span></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt; text-align: justify;">
<br /></div>
<br />
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><o:p> </o:p></span></div>
<br />
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><o:p> </o:p></span></div>
<br />
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><o:p> </o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><o:p> </o:p></span></b></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: "Times New Roman","serif"; font-size: 12pt; line-height: 115%;"><o:p> </o:p></span></b></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: "Times New Roman","serif"; font-size: 16pt; line-height: 115%;"><o:p><span style="text-decoration: none;"> </span></o:p></span></u></b></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<o:p><span style="font-family: Calibri;"> </span></o:p></div>
</div>
VINODhttp://www.blogger.com/profile/17567935148510637824noreply@blogger.com0tag:blogger.com,1999:blog-739950561508170142.post-44450978055145039932013-08-15T17:26:00.003+05:302013-08-15T17:26:42.427+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: center;">
<u><span style="font-size: x-large;">Just In Time Compiler</span></u></h2>
<div style="text-align: justify;">
We discussed in my previous blog about how JVM makes java program platform independent but "<i>everything in life comes at a cost</i>". Java's two pass execution to achieve this platform independence,The process of Java Compiler first compiling the java source code into byte code and then the JVM interpreting the .class files into native processor does take a toll on execution time of a typical Java program. Thus java programs run always slower than the native compiled languages like C. And adding to it interpreting the .class file's byte code instructions made the Java programs really very slow.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
So a lot of effort is and was invested on improving the execution speed of java programs. One of the breakthroughs of this effort is Just in Time Compilation.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now before moving to this topic a general question most of us will surely have is :</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>If interpreter is slow why not compile Byte code first and then run?</b></div>
<div style="text-align: justify;">
Please remember that we are not concerned about the programmer on how much time is spent on compiling a java code. All we are focused is about the user who runs our program and JVM comes into picture when JRE on a native platform is trying to run our program. Imagine how much time it may take to compile a whole bunch of .class files first and then load and start running it. The user may sleep while this happen. And the program loading will be terrible. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
So we must strike a right balance between this interpreting and compiling. And the answer as for as now with its own limitation which we will not cover here is Just in Time compilers.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The concept is derived from an inventory strategy companies employ to increase efficiency and decrease waste by receiving goods only when they are needed in production process there by reducing inventory costs.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Not all of code is used in a run cycle of a program. For example the error handling or certain conditional branching never happens in a particular run time of a program . So why compile entire code. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<i>"So JIT compilers of a JVM will compile the byte code into machine code only when it is referenced. And then JVM will execute it into native hardware. Functions are the smallest units and are compiled only when they are referenced."</i></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Though JIT looks concept wise simple there are lot of pitfalls of JIT especially during compile optimizations. This is not covered in this discussion. However people interested can go through the below post.</div>
<div style="text-align: justify;">
<span style="color: blue;"><br /></span></div>
<div style="text-align: justify;">
<span style="color: blue;"><a href="http://www.cse.iitd.ernet.in/~sbansal/csl862-virt/readings/CompileJava97.pdf">http://www.cse.iitd.ernet.in/~sbansal/csl862-virt/readings/CompileJava97.pdf</a></span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Hope things are clear. Please share your comments on this article.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
</div>
VINODhttp://www.blogger.com/profile/17567935148510637824noreply@blogger.com0tag:blogger.com,1999:blog-739950561508170142.post-34816847069810554952013-08-15T00:21:00.000+05:302013-08-15T08:06:02.615+05:30About Jdk,jre and jvm<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: justify;">
<u><span style="font-size: x-large;">Things to Know about JDK,JRE and JVM</span></u></h2>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
This is a favorite interview topic . Even though this is the most basic information a java programmer must know, many fail to answer it perfectly. I am making an attempt to rewrite this information so that it will refresh the concept of few experienced and will help java beginners to know concept in depth.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
The below diagram should make things clear.</div>
<div style="text-align: justify;">
</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQGvaq2AP0nzumWVj7DZe4VIQjJMgZsvgaiGGqflOLRlMiiEBIq_LIhoUZ5rZl_wuEYev7ZW1tJRbuTzZEuPLN0WAFdCHH2_qCA-50SDT010OhpZuJtStUzA1eUF__uSv0JANsT01eLoA/s1600/Jre1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQGvaq2AP0nzumWVj7DZe4VIQjJMgZsvgaiGGqflOLRlMiiEBIq_LIhoUZ5rZl_wuEYev7ZW1tJRbuTzZEuPLN0WAFdCHH2_qCA-50SDT010OhpZuJtStUzA1eUF__uSv0JANsT01eLoA/s320/Jre1.jpg" height="291" width="320" /></a></div>
<div style="text-align: justify;">
<b>JDK:</b></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Java Development Kit (JDK) = Java Runtime Environment (JRE) + Tools like compilers (JavaC)and debuggers necessary for developing java programs.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<b>JRE:</b></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
JRE = Java Virtual Machine(JVM) + Java Runtime Libraries + Components necessary to execute programs or applications written in java language.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<b>JVM:</b></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Programs written in Java are not directly compiled by Java Compiler (JavaC) for a particular hardware and operating system platform for execution.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Instead Java programs are compiled for an intermediate language called byte code which can be interpreted by an virtual machine [A software ] called Java Virtual Machine (JVM). And this interpreted code can now run on the actual hardware and OS.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
JVM thus makes java programs independent of the underlying hardware or operating system . So Java programs written on one platform need not change while attempted running it on a different code. Because Java programs are written for JVM's rather than actual machine it self.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Different platforms are provided with its on JRE which in turn includes the JVM for a particular platform. Means to say JVM for windows 32 bit machines and JVM for Linux 64 bit machines are different. However a java program written on the windows system can run on Linux 64 bit machine without any issues because, both JVM's can understand byte code.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
However while interpreting into actual machine language , individual JVM's will take care of interpreting it correctly.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
The below diagram should make things clear.</div>
<div style="text-align: justify;">
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijr-IyNLWfHQAltY0GPsUa3xtlB6fM5Bnw33DCsRmaRKvS4UrbM-tshbn0rY4kNXIcnU3f2YSI8NirnUBzdy0lX4rmSnBSjH6teTwLDb8rExZvfNN5A7vYs-oJYJE30XpSmAAZxy3KIa4/s1600/JVM.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijr-IyNLWfHQAltY0GPsUa3xtlB6fM5Bnw33DCsRmaRKvS4UrbM-tshbn0rY4kNXIcnU3f2YSI8NirnUBzdy0lX4rmSnBSjH6teTwLDb8rExZvfNN5A7vYs-oJYJE30XpSmAAZxy3KIa4/s320/JVM.jpg" height="248" width="320" /></a></div>
<div style="text-align: justify;">
But one thing with interpreting the byte code is that it will make the execution slower. Now newer JRE's have capability for Just in Time compilation [JIT] which makes the compilation much faster. </div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
I will write on this in my next blog. </div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Please share in your thoughts. Hope it benefited you.</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
<h2 class="MsoNormal" style="margin: 0in 0in 10pt; text-align: justify;">
</h2>
</div>
VINODhttp://www.blogger.com/profile/17567935148510637824noreply@blogger.com1Bangalore, Karnataka, India12.9715987 77.59456269999998312.4764182 76.949115699999979 13.4667792 78.240009699999987