<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Interview Questions &#187; Java Class Registering</title>
	<atom:link href="http://www.bestjavainterviewquestions.com/category/java-class-registering/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestjavainterviewquestions.com</link>
	<description>Java Interview Questions &#124; Core Java Interview Questions &#124; Advanced Java Interview Questions &#124; EJB Interview Questions &#124; J2EE Interview Questions &#124; Hibernate Interview Questions</description>
	<lastBuildDate>Fri, 03 Feb 2012 10:23:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Explain Java takes care of registering the driver</title>
		<link>http://www.bestjavainterviewquestions.com/explain-java-takes-care-of-registering-the-driver/</link>
		<comments>http://www.bestjavainterviewquestions.com/explain-java-takes-care-of-registering-the-driver/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 13:18:42 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Java Class Registering]]></category>
		<category><![CDATA[java database class register]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=426</guid>
		<description><![CDATA[Q) How Class.forName takes care of registering the drivers? Rep) (&#8220;oracle.jdbc.driver.OracleDriver()&#8221;); The driver vender provides a static block.As part of this block code will be provided to take care of registering the driver. When Class.forName is executed the class will be loaded and the static block of the class will be executed. The code in [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q) How Class.forName takes care of registering the drivers?</strong></p>
<p><strong>Rep) </strong>(&#8220;oracle.jdbc.driver.OracleDriver()&#8221;);</p>
<p>The driver vender provides a static block.As part of this block code will be provided to take care of registering the driver.</p>
<p>When Class.forName is executed the class will be loaded and the static block of the class will be executed. The code in the static block takes cares of registering the driver.</p>
<p>We can provide the code as shown below to make the application flexible (work with multiple database)</p>
<p>//dc :- your database connectivity class loading is here</p>
<p>Ex: for Oracle (&#8220;oracle:jdbc:driver:OracleDriver()&#8221;);</p>
<p>//Url :- your connection Driver with the username and password.</p>
<p>Ex: for Mysql(&#8220;jdbc:oracle:thin:@localhost:1521:xe&#8221;,&#8221;username&#8221;,&#8221;password&#8221;);</p>
<p>//username : your username for using database</p>
<p>//password : your password to that database</p>
<p>public class xxxx {</p>
<p>String Vdc = System.getProperty(&#8220;dc&#8221;);</p>
<p>String Vurl = System.getProperty(&#8220;url&#8221;);</p>
<p>String Vun = System.getProperty(&#8220;username&#8221;);</p>
<p>String Vpswd = System.getProperty(&#8220;password&#8221;);</p>
<p>{</p>
<p>Class.forName(&#8220;Vdl);</p>
<p>Connection con=DriverManager.getConnection(Vurl , Vun , Vpswd);</p>
<p>System.out.println(&#8220;&#8212;&#8212;-Connected&#8212;&#8211;&gt;&#8221;con.getClass());</p>
<p>}</p>
<p>}</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li>October 4, 2008 -- <a href="http://www.bestjavainterviewquestions.com/how-application-creates-a-connection/" title="How application creates a connection">How application creates a connection</a> (0)</li><li>November 27, 2008 -- <a href="http://www.bestjavainterviewquestions.com/making-a-frame-non-resizable-in-java/" title="Making a Frame Non-Resizable in Java ">Making a Frame Non-Resizable in Java </a> (0)</li><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/ejb-interview-questions/" title="EJB INTERVIEW QUESTIONS">EJB INTERVIEW QUESTIONS</a> (1)</li><li>July 7, 2008 -- <a href="http://www.bestjavainterviewquestions.com/java-garbage-collections/" title="Java Garbage Collections">Java Garbage Collections</a> (2)</li><li>October 3, 2008 -- <a href="http://www.bestjavainterviewquestions.com/jsp-scriplets-and-templets/" title="Jsp Scriplets and Templets">Jsp Scriplets and Templets</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/explain-java-takes-care-of-registering-the-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

