<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>椰子Java</title> 
<link>http:///index.php</link> 
<description>       我从事软件行业已经9年啦，2001毕业以后一直在成都从事软件开发工作，从事过电信行业相关软件开发和航空行业相关软件开发工作，2007回到了海南，回到了我的故乡。                                                                                                                                我经历了喜欢--狂热--疲倦--坚持--深爱上我的行业，因为它最体现我的价值。我对它了解越深就越能感觉到它的奇妙性，我可以在它虚拟出来的世界里任意翱翔。。。</description> 
<language>zh-cn</language> 
<copyright>Powered by Bo-blog 2.0.2 sp1</copyright>
<item>
<link>http:///read.php?699</link>
<title>JDBC数据结果对应的Java数据结构</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Sun, 23 Dec 2007 14:35:34 +0000</pubDate> 
<guid>http:///read.php?699</guid> 
<description>
<![CDATA[ 
	CHAR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.lang.String <br/>VARCHAR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.lang.String <br/>LONGVARCHAR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;java.lang.String <br/>NUMERIC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.math.BigDecimal <br/>DECIMAL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;java.math.BigDecimal <br/>BIT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boolean <br/>TINYINT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;byte <br/>SMALLINT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; short <br/>INTEGER &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int <br/>BIGINT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;long <br/>REAL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float <br/>FLOAT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; double <br/>DOUBLE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;double <br/>BINARY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;byte[] <br/>VARBINARY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;byte[] <br/>LONGVARBINARY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; byte[] <br/>DATE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.sql.Date <br/>TIME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.sql.Time <br/>TIMESTAMP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.sql.Timestamp <br/>CLOB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;java.sql.Clob <br/>BLOB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;java.sql.Blob <br/>ARRAY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.sql.Array <br/>DISTINCT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Mapping of underlying type <br/>STRUCT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.sql.Struct <br/>REF &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; java.sql.Ref <br/>
  ]]> 
</description>
</item><item>
<link>http:///read.php?633</link>
<title>注意外键的设置问题</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Mon, 08 Oct 2007 10:24:24 +0000</pubDate> 
<guid>http:///read.php?633</guid> 
<description>
<![CDATA[ 
	 &nbsp; &nbsp; &nbsp;我今天在修改航空维修管理系统的时候发现一个小失误造成的巨大麻烦，这个失误就是在做外键设置时候没有设置成为：ON DELETE CASCADE。当然在mysql也有这个问题。如果没有设置在删除主表的数据的时候那么从表的数据就要先删除，这是非常麻烦的。。。。<br/><br/> &nbsp; &nbsp;由于我的一个表没有设置结果造成删除实验数据要花3个小时，真是麻烦呀。。。血的教训呀。。。<br/><br/> &nbsp; &nbsp;顺便记录：<br/><br/> &nbsp; &nbsp;SQL级联删除与级联更新使用格式：<br/>CREATE TABLE A001（ID INT PRIMARY KEY，NAME VARCHAR（20））<br/>CREATE TABLE A002（ID INT REFERENCES A001（ID）ON DELETE CASCADE ON UPDATE CASCADE，AGE TINYINT）<br/><br/>ORACLE级联删除使用格式：<br/>CREATE TABLE A001（ID INT PRIMAY KEY，NAME VARCHAR2（20））<br/>CREATE TABLE A002（ID INT REFERENCES A001（ID）ON DELETE CASCADE，AGE NUMBER（2，0））<br/> &nbsp; &nbsp;Mysql:<br/><br/>ALTER TABLE `x1`<br/>ADD FOREIGN KEY (`Id`) REFERENCES `xxx` (`Id`);
  ]]> 
</description>
</item><item>
<link>http:///read.php?621</link>
<title>奇怪的Java数据库操作错误</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Thu, 27 Sep 2007 01:39:12 +0000</pubDate> 
<guid>http:///read.php?621</guid> 
<description>
<![CDATA[ 
	Error : java.sql.SQLException: 不允许的操作: Unsupported syntax for refreshRow()<br/><br/>我执行了一条sql:<br/><br/>select pn,partname,originname,engine_tm,parttype,unit,qty,fact_qty,price,price_money_type,o_money_type,f_money,owner,color,condition,location,dateapply,audittime,applyman,auditperson,auditresult,if_life, designation,description,form_id,income_id from v_sel_incomelist &nbsp;where dateapply between to_date('2007-09-27','yyyy-mm-dd') and to_date('2007-09-28','yyyy-mm-dd')+1 order by income_id<br/><br/>在sql plus 都是正确的。但是在JDBC就执行错误，真是奇怪。。。。。<br/><br/>order by income_id &nbsp;去掉也没有问题。<br/><br/>在网络上找了很多方法。好象大家最推崇的方法是使用10G的驱动。<br/><br/>我找到了，果真解决了。<br/><br/>Oracle JDBC Driver:<br/><a href="attachment/1190989555_0.rar">点击这里下载文件</a><br/>
  ]]> 
</description>
</item><item>
<link>http:///read.php?550</link>
<title>从国外找来的，对所有数据库的评价</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Fri, 10 Aug 2007 04:45:22 +0000</pubDate> 
<guid>http:///read.php?550</guid> 
<description>
<![CDATA[ 
	<a href="http:///attachment/1186721114_0.gif" target="_blank"><img src="http:///attachment/1186721114_0.gif" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a>
  ]]> 
</description>
</item><item>
<link>http:///read.php?531</link>
<title>叠加两条select语句的查询结果</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Tue, 24 Jul 2007 03:08:32 +0000</pubDate> 
<guid>http:///read.php?531</guid> 
<description>
<![CDATA[ 
	A sql: select a,b,c from ATable<br/>B sql: select a,b,c form BTable<br/><br/>全部叠加的：<br/><br/>select a,b,c from ATable union all (select a,b,c form BTable)<br/><br/>如果要去掉叠加以后相同的行，那么可以使用：<br/><br/>select distinct(a),b,c from (select a,b,c from ATable union all (select a,b,c form BTable))<br/><br/>这样得到的结果就是如果a列有相同的结果那么就可以去掉。
  ]]> 
</description>
</item><item>
<link>http:///read.php?502</link>
<title>数据库设计经验总结</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Wed, 27 Jun 2007 16:19:08 +0000</pubDate> 
<guid>http:///read.php?502</guid> 
<description>
<![CDATA[ 
	中午的时候和同时谈起来数据库设计的重要性，这里做一个总结以资鼓励！<br/><br/>第一：应该从骨子里面认识到数据库设计是非常重要的。<br/><br/>第二：一般的系统开发一定都是在原有的业务流基础上开发的，所以应该充分理解原有的业务流。<br/><br/>第三：先要设计Logic关系图，然后在做物理表。最后一定要形成标准的ER图。设计的时候应该重视符合3NF的要求。<br/><br/>第四：命名规范。<br/><br/>第五：文挡一定要规范，而且应该有文挡版本管理体系。<br/><br/>第六：在完成物理表设计以后应该建模，将数据流使用流程图的方式表示出来。<br/><br/>第七：在设计表的时候应该考虑以后扩展问题，例如有可能有些表需要不断的增加新的属性。那么应该为这个表建立一个新属性表，而不是经常修改表。<br/><br/>第八：在业务流要求非常严格的系统，不应该任意删除数据，因为这样会造成系统逻辑上的错误，所以应该增加一个属性字段用于表示数据已经失效。<br/><br/>第九：重视数据检索效率。可以利用数据库系统提高这个要求。
  ]]> 
</description>
</item><item>
<link>http:///read.php?496</link>
<title>java批量执行多条Sql语句</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Sat, 23 Jun 2007 08:26:00 +0000</pubDate> 
<guid>http:///read.php?496</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;/**<br/>&nbsp;&nbsp; * 执行多条更新的Sql语句<br/>&nbsp;&nbsp; */<br/>&nbsp;&nbsp;public boolean UpdataSql(String sql[]){<br/>&nbsp;&nbsp;&nbsp;&nbsp;TestConnect.Connect();&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp; &nbsp; &nbsp;try {<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;sta = TestConnect.connection.createStatement();<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;for(int i=0;i<sql.length;i++){<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sta.addBatch(sql[i]);&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;System.out.println("输出SQL语句："+sql[i]);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;&nbsp; &nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;sta.executeBatch();//执行<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return(true);<br/>&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;catch (Exception ex) {<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;System.out.println("Error : " + ex.toString());<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return(false);<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;}<br/>&nbsp;&nbsp; &nbsp; &nbsp;finally{<br/>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;try{<br/>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TestConnect.connection.commit();<br/>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sta.close();<br/>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TestConnect.connection.close();<br/>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;}catch(Exception e){<br/>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.printStackTrace();<br/>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;}&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp; &nbsp; &nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;}
  ]]> 
</description>
</item><item>
<link>http:///read.php?409</link>
<title>Java postgreSQL实验程序</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Thu, 19 Apr 2007 17:26:15 +0000</pubDate> 
<guid>http:///read.php?409</guid> 
<description>
<![CDATA[ 
	再花12分钟做好第一java连接PostgreSQL的程序。<br/><br/>JDBC用的是For 1.5这里一定要注意哦。不同的JDK使用驱动的版本不同，请认真查看http://jdbc.postgresql.org/<br/><br/>打包好的工程如下：<br/><br/>这个文件只能在登入之后下载。请先 <a href="login.php?job=register">注册</a> 或 <a href="login.php">登入</a><br/><br/>包含驱动和测试代码，请注意要先建立一个test数据库和员工表哦。<br/><br/>运行结果：<br/><br/>数据库连接成功！<br/>select * from employee<br/>用户Jason输出
  ]]> 
</description>
</item><item>
<link>http:///read.php?408</link>
<title>PostGreSQL第一次接触</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Thu, 19 Apr 2007 17:07:04 +0000</pubDate> 
<guid>http:///read.php?408</guid> 
<description>
<![CDATA[ 
	安装过程是非常简单的。安装过程完全可以在：http://pginstaller.projects.postgresql.org<br/>看到，但是我觉得如果大脑不残疾或则英语水平实在太差，应该是可以看明白的。<br/><br/>我想和别的软件安装不同的是：他需要建立一个用户，如果常用linux或unix的人就明白为什么了。<br/><br/>安装完后在默认的管理工具pgAdmin III中可以建立一个数据库，然后使用SQL语言：<br/><br/>CREATE TABLE employee (<br/>ID &nbsp; &nbsp; &nbsp; &nbsp; int,<br/>name &nbsp; &nbsp; &nbsp; varchar(10),<br/>salary &nbsp; &nbsp; real,<br/>start_date date,<br/>city &nbsp; &nbsp; &nbsp; varchar(10),<br/>region &nbsp; &nbsp; char(1));<br/><br/>insert into employee (ID, name, &nbsp; &nbsp;salary, start_date, city, region) values (1, &nbsp;'Jason',40420, &nbsp;'02/01/94', 'New York', 'W');<br/><br/>插入成功！<br/><br/>结果如下：<br/><br/><br/><a href="http:///attachment/1177002312.jpg" target="_blank"><img src="http:///attachment/1177002312.jpg" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>很简单吧，其他象设置UK啊什么的，就不需要多说啦。<br/><br/>搞定！花了1个小时20分钟，我将关注他的发展，希望他会成为我商业开发里的一个新成员。。。。。。。期待中。
  ]]> 
</description>
</item><item>
<link>http:///read.php?357</link>
<title>java操作Sql总结</title> 
<author>fubin &lt;yonghe169@163.com&gt;</author>
<category>数据库</category>
<pubDate>Wed, 14 Mar 2007 05:00:55 +0000</pubDate> 
<guid>http:///read.php?357</guid> 
<description>
<![CDATA[ 
	1、建立连接<br/> &nbsp; &nbsp;这个是一切连接数据库的基础，当然这个也比较简单。<br/> &nbsp; &nbsp;一下是一个连接Sql2000的数据库程序，还有一个显示一个表的方法。<br/>import java.*; <br/><br/>public class ConnectData{ <br/>&nbsp;&nbsp;<br/>private java.sql.Connection con = null; <br/>private java.sql.Statement stmt=null; <br/>private final String url = "jdbc:microsoft:sqlserver://"; <br/>private final String serverName= "192.168.0.100"; <br/>private final String portNumber = "1433"; <br/>private final String databaseName= "hkmis"; //数据库名称<br/>//mydata是手动建的数据库 <br/>private final String userName = "hkmisuser"; <br/>private final String password = "hkmis123456"; <br/><br/>public ConnectData(){} <br/>private String getConnectionUrl(){ <br/>return url+serverName+":"+portNumber+";databaseName="+databaseName+";"; <br/>} <br/><br/>private java.sql.Connection getConnection(){ <br/>try{ <br/>Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); <br/>con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password); <br/>if(con!=null) System.out.println("Connection Successful!"); <br/>}catch(Exception e){ <br/>e.printStackTrace(); <br/>System.out.println("Error Trace in getConnection() : " + e.getMessage()); <br/>} <br/>return con; <br/>} <br/>/* <br/>用于显示一个表<br/>*/ <br/>public void displayData(){ <br/>java.sql.ResultSet rs = null; <br/>try{ <br/>con= this.getConnection(); <br/>if(con!=null){ <br/>stmt=con.createStatement(); <br/>rs=stmt.executeQuery("select * from userinfo"); <br/>//userinfo是mydata中的用户信息表（username，password） &nbsp;<br/>while(rs.next()){ <br/>System.out.println( rs.getString("username")); //显示所有用户<br/>//System.out.println( rs.getString(2)); <br/>//System.out.println( rs.getString(3));<br/>} <br/>rs.close(); //这里一定要记得关闭顺序<br/>//先关闭ResultSet，然后关闭Statement(或者PreparedStatement);最后关闭Connection<br/>rs = null; <br/>closeConnection(); <br/>}else System.out.println("Error: No active Connection"); <br/>}catch(Exception e){ <br/>e.printStackTrace(); <br/>} <br/><br/>} <br/>private void closeConnection(){ <br/>try{ <br/>if(con!=null) <br/>con.close(); <br/>con=null; <br/>}catch(Exception e){ <br/>e.printStackTrace(); <br/>} <br/>} <br/>//执行测试。。。<br/>public static void main(String[] args) throws Exception <br/>{ <br/>ConnectData myDbTest = new ConnectData(); <br/>myDbTest.displayData(); <br/>} <br/>} <br/> &nbsp; &nbsp; 这里要强调的是，不同的数据库除了使用的Driver不同之外，连接的方式也是不同的，例如，mysql最好加上字体参数，以免出现乱码。而oracle就不需要规定数据库名称。<br/><br/>2、执行sql语句<br/>　　1)用Statement来执行sql语句<br/>　　String sql;<br/>　　Statement sm = cn.createStatement();<br/>　　sm.executeQuery(sql); // 执行数据查询语句(select)<br/>　　sm.executeUpdate(sql); // 执行数据更新语句(delete、update、insert、drop等)statement.close();<br/>　　2)用PreparedStatement来执行sql语句<br/>　　String sql;<br/>　　sql = "insert into user (id,name) values (?,?)";<br/>　　PreparedStatement ps = cn.prepareStatement(sql);<br/>　　ps.setInt(1,xxx);<br/>　　ps.setString(2,xxx);<br/>　　...<br/>　　ResultSet rs = ps.executeQuery(); // 查询<br/>　　int c = ps.executeUpdate(); // 更新<br/>　　3、处理执行结果<br/>　　查询语句，返回记录集ResultSet<br/>　　更新语句，返回数字，表示该更新影响的记录数<br/>　　ResultSet的方法<br/>　　1、next()，将游标往后移动一行，如果成功返回true;否则返回false<br/>　　2、getInt("id")或getSting("name")，返回当前游标下某个字段的值<br/>　　4、释放连接<br/>　　cn.close();<br/>　　一般，先关闭ResultSet，然后关闭Statement(或者PreparedStatement);最后关闭Connection<br/>　　可滚动、更新的记录集<br/>　　1、创建可滚动、更新的Statement<br/>　　Statement sm = cn.createStatement(ResultSet.TYPE_SCROLL_ENSITIVE,ResultSet.CONCUR_READ_ONLY);<br/>　　该Statement取得的ResultSet就是可滚动的<br/>　　2、创建PreparedStatement时指定参数<br/>　　PreparedStatemet ps = cn.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);<br/>　　ResultSet.absolute(9000);<br/>　　·批量更新，这个非常重要，是多Sql语句结合体的方法。<br/>　　1、Statement<br/>　　Statement sm = cn.createStatement();<br/>　　sm.addBatch(sql1);<br/>　　sm.addBatch(sql2);<br/>　　...<br/>　　sm.executeBatch()<br/>　　一个Statement对象，可以执行多个sql语句以后，批量更新。这多个语句可以是delete、update、insert等或兼有<br/>　　2、PreparedStatement<br/>　　PreparedStatement ps = cn.preparedStatement(sql);<br/>　　{<br/>　　ps.setXXX(1,xxx);<br/>　　...<br/>　　ps.addBatch();<br/>　　}<br/>　　ps.executeBatch();<br/>　　一个PreparedStatement，可以把一个sql语句，变换参数多次执行，一次更新。<br/>　　·事务的处理<br/>　　1、关闭Connection的自动提交，这在oracle中效果非常明显。<br/>　　cn.setAutoCommit(false);<br/>　　2、执行一系列sql语句<br/>　　要点：执行每一个新的sql语句前，上一次执行sql语句的Statement(或者PreparedStatemet)必须先close<br/>　　Statement sm ;<br/>　　sm = cn.createStatement(insert into user...);<br/>　　sm.executeUpdate();<br/>　　sm.close();<br/>　　sm = cn.createStatement("insert into corp...);<br/>　　sm.executeUpdate();<br/>　　sm.close();<br/>　　3、提交<br/>　　cn.commit();<br/> &nbsp; &nbsp; &nbsp;4、如果发生异常，那么回滚。例如发现插入不完整时候，都应该回滚保证数据的完整性。<br/>　　cn.rollback();
  ]]> 
</description>
</item>
</channel>
</rss>