<?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>The World Of Gavin &#187; jdbc</title>
	<atom:link href="http://www.gavinwillingham.com/tag/jdbc/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gavinwillingham.com</link>
	<description>My opinions on things I have opinions on</description>
	<lastBuildDate>Fri, 28 Jan 2011 17:08:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>DB2 and JDBC</title>
		<link>http://www.gavinwillingham.com/db2-and-jdbc.html</link>
		<comments>http://www.gavinwillingham.com/db2-and-jdbc.html#comments</comments>
		<pubDate>Sun, 20 Sep 2009 12:07:49 +0000</pubDate>
		<dc:creator>gavin</dc:creator>
				<category><![CDATA[Content]]></category>
		<category><![CDATA[db2]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jdbc]]></category>

		<guid isPermaLink="false">http://www.gavinwillingham.com/?p=79</guid>
		<description><![CDATA[You need to include db2jcc.jar db2jcc_license_cu.jar on the classpath of the application. These can be found in the java/ sub-directory of the db2 install directory (Program Files/IBM/SQLLIB for me on Windows). Connecting The connection server string depends on whether you are using type2 or type4. Type 1: JDBC-ODBC Bridge Type 2: Native-API/partly Java driver Type [...]]]></description>
			<content:encoded><![CDATA[<p>You need to include</p>
<ul>
<li>db2jcc.jar</li>
<li>db2jcc_license_cu.jar</li>
</ul>
<p>on the classpath of the application. These can be found in the <code>java/</code> sub-directory of the db2 install directory (<code>Program Files/IBM/SQLLIB</code> for me on Windows).</p>
<h2>Connecting</h2>
<p>The connection server string depends on whether you are using type2 or type4.</p>
<blockquote>
<ul>
<li>Type 1: JDBC-ODBC Bridge</li>
<li>Type 2: Native-API/partly Java driver</li>
<li>Type 3: Net-protocol/all-Java driver</li>
<li>Type 4: Native-protocol/all-Java driver</li>
</ul>
<p><span class="citation">Source: http://www.javaworld.com/javaworld/jw-07-2000/jw-0707-jdbc.html</span></p></blockquote>
<h3>Type2:</h3>
<p><code>jdbc:db2:database</code></p>
<h3>Type4:</h3>
<p><code>jdbc:db2//server[:port]/database</code></p>
<h3>Sample code</h3>
<p>Opens a connection, executes a query and then closes the connection.<br />
<code></p>
<pre>
/* Load the driver */
Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();

/* open the connection */
Connection conn = DriverManager.getConnection(url, user, password);

Statement st = conn.createStatement();

/* Execute a simple query to test the connection */
ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM myTable");
rs.next();

/* Print the query results */
System.out.println(rs.getInt(1));

/* don't forget to close the connection */
conn.close();</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gavinwillingham.com/db2-and-jdbc.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

