<?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>Li Guoliang &#187; JDBC</title>
	<atom:link href="http://liguoliang.com/tag/jdbc/feed/" rel="self" type="application/rss+xml" />
	<link>http://liguoliang.com</link>
	<description>ActionScript Flex Java JEE PHP...</description>
	<lastBuildDate>Mon, 21 May 2012 17:04:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>SQL中判断时间</title>
		<link>http://liguoliang.com/2010/set-date-in-ejbql/</link>
		<comments>http://liguoliang.com/2010/set-date-in-ejbql/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 12:58:29 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/set-date-in-ejbql/</guid>
		<description><![CDATA[需求: (使用JDBC) 在SQL中增加时间限制
简单错误的写法:
SimpleDateFormat df = new SimpleDateFormat(&#8220;yyyy-MM-dd&#8221;);
String dateNow = df.format(new Date(System.cur<p class='read-more'><a href='http://liguoliang.com/2010/set-date-in-ejbql/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>需求: (使用JDBC) 在SQL中增加时间限制</p>
<p>简单错误的写法:</p>
<p>SimpleDateFormat df = new SimpleDateFormat(&#8220;yyyy-MM-dd&#8221;);<br />
String dateNow = df.format(new Date(System.currentTimeMillis())); //&#8221;2010-11-19&#8243;; //new Date(System.currentTimeMillis()).toString();<br />
然后将dateNow加入到SQL中. maybe可工作, 但<strong>不能保证数据库平台迁移后仍可继续工作.</strong></p>
<p><strong>正确的解决方法, 使用PreparedStatement设定SQL参数:</strong></p>
<pre class="java">StringBuilder sb = new StringBuilder("SELECT oue FROM OUEnroll oue WHERE oue.user_ID = ");
		sb.append(user.getUser_ID()).append("  AND (oue.dateStart IS NULL OR ").append("?2")...

// 省略若干
		select.setParameter(1, user.getUser_ID());
		select.setParameter(2, new Date(System.currentTimeMillis()));</pre>
<p>JDBC会根据具体的数据库Driver处理Date并加入到SQL中.</p>
<p>&nbsp;</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/set-date-in-ejbql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>通过JDBC使用DB2 ALTOBJ存储过程Alter Column</title>
		<link>http://liguoliang.com/2010/jdbc-alter-column-with-db2-altobj-procedure/</link>
		<comments>http://liguoliang.com/2010/jdbc-alter-column-with-db2-altobj-procedure/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 09:04:20 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[DB]]></category>
		<category><![CDATA[Alter Column]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[Procedure]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/jdbc-alter-column-with-db2-altobj-procedure/</guid>
		<description><![CDATA[本文将简述通过JDBC呼叫DB2的ALTOBJ存储过程, 以进行Column的Alter操作.<p class='read-more'><a href='http://liguoliang.com/2010/jdbc-alter-column-with-db2-altobj-procedure/'></a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>本文将简述通过JDBC呼叫DB2的ALTOBJ存储过程, 以进行Column的Alter操作.   <br />API: <a href="http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0011934.htm">http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0011934.htm</a></p>
<h3><strong>ALTOBJ procedure Alter column 须知:</strong> </h3>
<p>1. 对于Alter Column的操作, 如: 重命名, 修改数据类型, 修改nullable, 扩大数据范围等操作, 不可通过单纯的SQL语句执行. 需要呼叫ALTOBJ存储过程进行修改.</p>
<p>2. 如果使用ATLOBJ 修改Column, Column的数据,&#160; 原有PrimaryKey, 相关的Index, 都不会改变.</p>
<p>3. 特别的, 对于重命名列:</p>
<p>- 如果为PrimaryKey, DB2在重新创建Table时会使用新的名称创建主键.</p>
<p>-&#160; 但对于有关的Index &#8211; 在重建时, DB2使用旧的名称创建Index, 会出现错误, 解决方法是在呼叫存储过程前, 先Drop被重命名的Column对应的Index, 在存储过程呼叫完毕(Table已重建)后, 再次Create Index即可.</p>
<p>4. 对于修改Default/AutoIncrement, 可通过单纯的SQL Alert语句执行就可完成.</p>
<h3><strong>使用ALTOBJ存储过程AlertColumn举例:</strong></h3>
<p>以下重命名一个Column (由db2 Control Center show sql生成):</p>
<p>CALL SYSPROC.ALTOBJ ( &#8216;APPLY_CONTINUE_ON_ERROR&#8217;, &#8216;CREATE TABLE TB6 (    <br />&#160; ID INTEGER NOT NULL&#160; GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1),     <br />&#160; NAME3 INTEGER&#160; DEFAULT 96 ) IN USERSPACE1 COMPRESS YES &#8216;, -1, ? )</p>
<p>注意: 该语句只能在DB2工具中使用, 还不能直接在JDBC中.</p>
<p><strong>在JDBC中使用ALTOBJ Alert Column:</strong> </p>
<p>按照API中ALTOBJ procedure的说明: 第一个参数(上面语句-1处), 为INOUT类型, 既作为输入参数又作为输出参数(<a href="http://liguoliang.com/2010/jdbc-callablestatement-inout-parameter/" target="_blank">INOUT参数介绍</a>), 因此在JDBC使用时会要求注册out parameter, 在JDBC中则需要使用:</p>
<pre class="java" name="code">String sql = &quot;CALL SYSPROC.ALTOBJ ( 'APPLY_CONTINUE_ON_ERROR', 'CREATE TABLE TB6 (
  ID INTEGER NOT NULL  GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1),
  NAME3 INTEGER  DEFAULT 96 ) IN USERSPACE1 COMPRESS YES ', ?, ? ))&quot;;
	// 第一个参数为INOUT参数, 第二个为OUT 

        CallableStatement proc = connection.prepareCall(sql);
        proc.setInt(1, -1); // 作为IN时, 提供Value
        proc.registerOutParameter(1, Types.INTEGER);  // 作为OUT时 注册输出参数

        proc.registerOutParameter(2, Types.VARCHAR); // 第二个参数为OUT参数, 仅注册.

proc.executeUpdate();</pre>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/jdbc-alter-column-with-db2-altobj-procedure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB2 SQL0469N SQLCode-469 SQLSTATE:42886 错误解决</title>
		<link>http://liguoliang.com/2010/db2-sql0469n-sqlcode-469-sqlstate42886/</link>
		<comments>http://liguoliang.com/2010/db2-sql0469n-sqlcode-469-sqlstate42886/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 16:58:34 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[DB]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/db2-sql0469n-sqlcode-469-sqlstate42886/</guid>
		<description><![CDATA[<p>今天在使用JDBC呼叫DB2存储过程时, 出现如题错误.</p>
<p>因为SQL代码在DB2 Editor中运行无误, 但使用JDBC屡屡出错, 最终原因在于在JDBC中INOUT参数只IN未OUT.</p>
<p>DB2CC中自动生成的SQL中直接设定了IN的Value, 但实际要求为INOUT参数, 在JDBC中使用时便会报错.</p>
<p>解决方法为: 查看对应存储过程的API, 修改SQL语句(注意: db2cc自动生成的SQL可能并不适用于JDBC, 还应以API为准).</p>
<p></p><p class='read-more'><a href='http://liguoliang.com/2010/db2-sql0469n-sqlcode-469-sqlstate42886/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>今天在使用JDBC呼叫DB2存储过程时, 出现如题错误.</p>
<p>因为SQL代码在DB2 Editor中运行无误, 但使用JDBC屡屡出错, 最终原因在于在JDBC中INOUT参数只IN未OUT.</p>
<p>DB2CC中自动生成的SQL中直接设定了IN的Value, 但实际要求为INOUT参数, 在JDBC中使用时便会报错.</p>
<p>解决方法为: 查看对应存储过程的API, 修改SQL语句(注意: db2cc自动生成的SQL可能并不适用于JDBC, 还应以API为准).</p>
<p><span id="more-1606"></span></p>
<p>附录:API信息:</p>
<p><a title="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.msg.doc/doc/sql0469.htm" href="http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.msg.doc/doc/sql0469.htm">http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.msg.doc/doc/sql0469.htm</a></p>
<h5>SQL0469</h5>
<p>SQL0469N</p>
<p>The parameter mode (IN, OUT, or INOUT) is not valid for a parameter in procedure procedure-name with specific name specific-name (parameter number number, name parameter-name).</p>
<p>Explanation:</p>
<p>One of the following errors occurred:</p>
<ul>
<li>a parameter in an SQL procedure is declared as OUT and is used as input in the procedure body</li>
<li>a parameter in an SQL procedure is declared as IN and is modified in the procedure body.</li>
</ul>
<p>User response:</p>
<p>Change the attribute of the parameter to INOUT, or change the use of the parameter within the procedure.</p>
<p><strong>sqlcode</strong>: -469</p>
<p><strong>sqlstate</strong>: 42886</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/db2-sql0469n-sqlcode-469-sqlstate42886/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JDBC CallableStatement INOUT Parameter 参数使用</title>
		<link>http://liguoliang.com/2010/jdbc-callablestatement-inout-parameter/</link>
		<comments>http://liguoliang.com/2010/jdbc-callablestatement-inout-parameter/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 16:48:03 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[INOUT]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/jdbc-callablestatement-inout-parameter/</guid>
		<description><![CDATA[INOUT参数既作输入又做输出用.&#160; 除了需要使用set<em>DataType</em>(<em>value</em>)之外, 还需要registerOutParameter. 例如: 
String sql = &#34;CALL ALTOBJ ( SOMETHING, ?, ?)&#34;; // 第一个参数为IN<p class='read-more'><a href='http://liguoliang.com/2010/jdbc-callablestatement-inout-parameter/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>INOUT参数既作输入又做输出用.&#160; 除了需要使用set<em>DataType</em>(<em>value</em>)之外, 还需要registerOutParameter. 例如: </p>
<pre class="java" name="code">String sql = &quot;CALL ALTOBJ ( SOMETHING, ?, ?)&quot;; // 第一个参数为INOUT参数, 第二个为OUT 

        CallableStatement proc = connection.prepareCall(sql);
        proc.setInt(1, -1); // 作为IN时, 提供Value
        proc.registerOutParameter(1, Types.INTEGER);  // 作为OUT时 注册输出参数

        proc.registerOutParameter(2, Types.VARCHAR); // 第二个参数为OUT参数, 仅注册.

proc.executeUpdate();</pre>
<p>See: </p>
<p>JDBC基础教程之CallableStatement <a href="http://www.java-cn.com/club/html/42/n-4942.html">http://www.java-cn.com/club/html/42/n-4942.html</a></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/jdbc-callablestatement-inout-parameter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DB2获得表内主键 Get PrimaryKeys</title>
		<link>http://liguoliang.com/2010/get-primarykeys-in-db2/</link>
		<comments>http://liguoliang.com/2010/get-primarykeys-in-db2/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 06:50:36 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[DB]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[Primary key]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/get-primarykeys-in-db2/</guid>
		<description><![CDATA[<p>SQL:</p>
<p>SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR NOT LIKE &#8216;SYS%&#8217; AND TBNAME = &#8216;<em>TABLENAME</em>&#8216; AND KEYSEQ &#62; 0 ORDER BY KEYSEQ ASC;</p>
<p> </p><p class='read-more'><a href='http://liguoliang.com/2010/get-primarykeys-in-db2/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>SQL:</p>
<p>SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR NOT LIKE &#8216;SYS%&#8217; AND TBNAME = &#8216;<em>TABLENAME</em>&#8216; AND KEYSEQ &gt; 0 ORDER BY KEYSEQ ASC;</p>
<p> <span id="more-1577"></span>
<p>Use in jdbc:</p>
<pre class="java" name="code">resultSet = statement.executeQuery(sql);
while(resultSet.next()) {
                System.out.println(resultSet.getString(&quot;NAME&quot;));
}</pre>
<p>&#160;</p>
<p>See: <a href="http://database.ittoolbox.com/groups/technical-functional/db2-l/how-to-find-a-primary-keys-and-foreign-keys-in-a-db2-table-268468?exp=1">http://database.ittoolbox.com/groups/technical-functional/db2-l/how-to-find-a-primary-keys-and-foreign-keys-in-a-db2-table-268468?exp=1</a></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/get-primarykeys-in-db2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用JDBC获取DB2的所有表(getTables)</title>
		<link>http://liguoliang.com/2010/gettables-db2-with-jdbc/</link>
		<comments>http://liguoliang.com/2010/gettables-db2-with-jdbc/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 15:15:45 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[DB]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[getTables]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/gettables-db2-with-jdbc/</guid>
		<description><![CDATA[直接使用metadata.getTables似乎不能获取DB2中指定Database下的所有Table, 但可使用如下语句获取: 
&#34;SELECT CREATOR,NAME FROM SYSIBM.SYSTABLES WHERE CREATOR NOT LIKE &#8216;SYS%&#<p class='read-more'><a href='http://liguoliang.com/2010/gettables-db2-with-jdbc/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>直接使用metadata.getTables似乎不能获取DB2中指定Database下的所有Table, 但可使用如下语句获取: </p>
<p>&quot;SELECT CREATOR,NAME FROM SYSIBM.SYSTABLES WHERE CREATOR NOT LIKE &#8216;SYS%&#8217;&quot;;</p>
<p>参考链接: </p>
<p>View Tables of DB2 Database using JDBC <a href="http://bytes.com/topic/db2/answers/704725-view-tables-db2-database-using-jdbc">http://bytes.com/topic/db2/answers/704725-view-tables-db2-database-using-jdbc</a></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/gettables-db2-with-jdbc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用JDBC type4连接DB2</title>
		<link>http://liguoliang.com/2010/jdbc-connect-db2-type4/</link>
		<comments>http://liguoliang.com/2010/jdbc-connect-db2-type4/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 14:57:25 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[DB]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/jdbc-connect-db2-type4/</guid>
		<description><![CDATA[简单介绍使用JDBC4连接DB2<p class='read-more'><a href='http://liguoliang.com/2010/jdbc-connect-db2-type4/'></a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>1. 首先要在工程中加入DB2连接文件db2jcc.jar, 该文件可从DB2安装目录中找到.    <br />2. 建立连接: </p>
<pre class="java" name="code">	public void setUp() throws Exception {
		Class.forName(&quot;com.ibm.db2.jcc.DB2Driver&quot;).newInstance();
		Properties connProperties = new Properties();
		connProperties.put(&quot;user&quot;, &quot;ADMINISTRATOR&quot;);
		connProperties.put(&quot;password&quot;, &quot;liguoliang.com&quot;);

		connection = DriverManager.getConnection(db2.getJdbcUrl(&quot;192.168.1.113&quot;, 50000, &quot;meta&quot;), connProperties);
	}</pre>
<p>3. 执行SQL语句举例:</p>
<pre class="java" name="code">	public void validateConnection(Connection connection) throws SQLException {
		if(connection == null) {
			throw new SQLException(&quot;Connection is null&quot;);
		}

		Statement stmt = null;
		ResultSet rs = null;

		try {
			stmt = connection.createStatement();
			rs = stmt.executeQuery(&quot;VALUES(1)&quot;); // 该语句将返回1
			rs.next();
			if(rs.getInt(1) != 1) {
				throw new SQLException(&quot;SQL Exception: values(1) != 1&quot;);
			}
		}finally {
			JDBCUtilities.close(rs);
		}
	}</pre>
<p>有用的链接: </p>
<h4><a href="http://www.blogjava.net/nighty/archive/2008/04/17/193681.html">JDBC连接DB2的一些总结</a></h4>
<p>用java访问数据库DB2代码的实际操作&#160; <a title="http://database.51cto.com/art/201008/216908.htm" href="http://database.51cto.com/art/201008/216908.htm">http://database.51cto.com/art/201008/216908.htm</a></p>
<p>使用 JDBC 连接不同版本 DB2 数据库的兼容性问题 <a href="http://www.ibm.com/developerworks/cn/data/library/techarticles/0402chenjunwei/0402chenjunwei.html#author1">http://www.ibm.com/developerworks/cn/data/library/techarticles/0402chenjunwei/0402chenjunwei.html#author1</a></p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/jdbc-connect-db2-type4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>通过JDBC连接DB2错误Connection timed out错误排除</title>
		<link>http://liguoliang.com/2010/jdbc-db2-disconnectnontransientconnectionexception/</link>
		<comments>http://liguoliang.com/2010/jdbc-db2-disconnectnontransientconnectionexception/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 14:45:25 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[DB]]></category>
		<category><![CDATA[DB2]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/jdbc-db2-disconnectnontransientconnectionexception/</guid>
		<description><![CDATA[<p>com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550][3.59.81] Exception java.net.ConnectException: Error opening socket to server /192.168.1.113 on port 50,000 with message: Connection timed out: connect. ERRORCODE=-4499, SQLSTATE=08001</p>
<p>第一次使用JDBC连接DB2数据库时, 出现上述错误. </p>
<p> </p><p class='read-more'><a href='http://liguoliang.com/2010/jdbc-db2-disconnectnontransientconnectionexception/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550][3.59.81] Exception java.net.ConnectException: Error opening socket to server /192.168.1.113 on port 50,000 with message: Connection timed out: connect. ERRORCODE=-4499, SQLSTATE=08001</p>
<p>第一次使用JDBC连接DB2数据库时, 出现上述错误. </p>
<p> <span id="more-1568"></span>
<p>解决方法: </p>
<p>1. 使用客户机telnet 到 DB2服务器的指定端口, 发现无法连接, 怀疑DB2未启动或Instance的端口有问题</p>
<p>2. 进入DB2所在服务器, telnet成功</p>
<p>3. 关闭服务器防火墙, 客户端重新连接, 正常.</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/jdbc-db2-disconnectnontransientconnectionexception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[旧]Java: JDBC 取得ResultSet的长度</title>
		<link>http://liguoliang.com/2010/%e6%97%a7java-jdbc-%e5%8f%96%e5%be%97resultset%e7%9a%84%e9%95%bf%e5%ba%a6/</link>
		<comments>http://liguoliang.com/2010/%e6%97%a7java-jdbc-%e5%8f%96%e5%be%97resultset%e7%9a%84%e9%95%bf%e5%ba%a6/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 10:19:17 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/08/1476/</guid>
		<description><![CDATA[JDBC 取得ResultSet的长度:

	resultSet.last(); // 游标移到最后, 获得rs长度
			int length = resultSet.getRow();
			resultSet.first(); // 还原游标到rs开头



----------Post <p class='read-more'><a href='http://liguoliang.com/2010/%e6%97%a7java-jdbc-%e5%8f%96%e5%be%97resultset%e7%9a%84%e9%95%bf%e5%ba%a6/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<p>JDBC 取得ResultSet的长度:
<pre name="code" class="java">
	resultSet.last(); // 游标移到最后, 获得rs长度
			int length = resultSet.getRow();
			resultSet.first(); // 还原游标到rs开头
</pre>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/%e6%97%a7java-jdbc-%e5%8f%96%e5%be%97resultset%e7%9a%84%e9%95%bf%e5%ba%a6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[旧文存档]JDBC: java.sql.SQLException: 结果集已耗尽 &amp; 对只转发结果集的无效操作</title>
		<link>http://liguoliang.com/2010/%e6%97%a7%e6%96%87%e5%ad%98%e6%a1%a3jdbc-java-sql-sqlexception-%e7%bb%93%e6%9e%9c%e9%9b%86%e5%b7%b2%e8%80%97%e5%b0%bd-%e5%af%b9%e5%8f%aa%e8%bd%ac%e5%8f%91%e7%bb%93%e6%9e%9c%e9%9b%86%e7%9a%84/</link>
		<comments>http://liguoliang.com/2010/%e6%97%a7%e6%96%87%e5%ad%98%e6%a1%a3jdbc-java-sql-sqlexception-%e7%bb%93%e6%9e%9c%e9%9b%86%e5%b7%b2%e8%80%97%e5%b0%bd-%e5%af%b9%e5%8f%aa%e8%bd%ac%e5%8f%91%e7%bb%93%e6%9e%9c%e9%9b%86%e7%9a%84/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 10:01:47 +0000</pubDate>
		<dc:creator>Guoliang</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java.sql.SQLException]]></category>
		<category><![CDATA[JDBC]]></category>

		<guid isPermaLink="false">http://liguoliang.com/2010/08/1472/</guid>
		<description><![CDATA[1. java.sql.SQLException: 结果集已耗尽 
原因: 执行的数据库查询没有查询到任何结果，却调用了resultSet.next(). 
2. java.sql.SQLException: 对只转发结果集的无效操作:
 如果conn在创建时, 若不给定参数，预设是ResultSe<p class='read-more'><a href='http://liguoliang.com/2010/%e6%97%a7%e6%96%87%e5%ad%98%e6%a1%a3jdbc-java-sql-sqlexception-%e7%bb%93%e6%9e%9c%e9%9b%86%e5%b7%b2%e8%80%97%e5%b0%bd-%e5%af%b9%e5%8f%aa%e8%bd%ac%e5%8f%91%e7%bb%93%e6%9e%9c%e9%9b%86%e7%9a%84/'>More...</a></p><p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></description>
			<content:encoded><![CDATA[<h3>1. java.sql.SQLException: 结果集已耗尽 </h3>
<p>原因: 执行的数据库查询没有查询到任何结果，却调用了resultSet.next(). </p>
<h3>2. java.sql.SQLException: 对只转发结果集的无效操作:</h3>
<p> 如果conn在创建时, 若不给定参数，预设是ResultSet.TYPE_FORWARD_ONLY、 ResultSet.CONCUR_READ_ONL, 此时不可进行游标操作, 会报错: java.sql.SQLException: 对只转发结果集的无效操作.    <br />欲操作游标, 则应使用stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);</p>
<p><p>

----------Post from: <a href="http://liguoliang.com">@LiGuoliang.com, 欢迎回来~</a>----------</p></p>
]]></content:encoded>
			<wfw:commentRss>http://liguoliang.com/2010/%e6%97%a7%e6%96%87%e5%ad%98%e6%a1%a3jdbc-java-sql-sqlexception-%e7%bb%93%e6%9e%9c%e9%9b%86%e5%b7%b2%e8%80%97%e5%b0%bd-%e5%af%b9%e5%8f%aa%e8%bd%ac%e5%8f%91%e7%bb%93%e6%9e%9c%e9%9b%86%e7%9a%84/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

