var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-20738293-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script')"/>
<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    jutleo
    歡迎走進有風的地方~~
    posts - 63,  comments - 279,  trackbacks - 0
    package JDBC;

    import java.sql.BatchUpdateException;
    import java.sql.Connection;
    import java.sql.Date;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.sql.Time;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    /**
     * 
     * 
    @author oakertree
     *
     
    */

    public class TestTransaction {
        
    public static void main(String[] args) {
            Connection con 
    = null;
            Statement stmt 
    = null;
    //        PreparedStatement stmt = null;
            
            
    try {
                Class.forName(
    "com.mysql.jdbc.Driver");
    //            new com.mysql.jdbc.Driver();
                con = DriverManager.getConnection("jdbc:mysql://localhost:3307/test""root""admini");
                
                con.setAutoCommit(
    false);
                
                stmt 
    = con.createStatement();
                stmt.addBatch(
    "INSERT INTO time VALUES ( NOW(), NOW(), NOW())");
                stmt.addBatch(
    "INSERT INTO time VALUES ( NOW(), NOW(), NOW())");
                stmt.addBatch(
    "INSERT INTO time VALUES ( NOW(), NOW(), NOW())");
                stmt.addBatch(
    "INSERT INTO time VALUES ( NOW(), NOW(), NOW())");
                stmt.addBatch(
    "INSERT INTO time VALUES ( NOW(), NOW(), NOW())");
                stmt.addBatch(
    "INSERT INTO time VALUES ( NOW(), NOW(), NOW())");
                stmt.executeBatch();
                
                con.commit();
                con.setAutoCommit(
    true);
                
                stmt.close();
                
    /*
                System.out.println(Date.valueOf("2004-02-19"));
                System.out.println(Time.valueOf("14:29:32"));
                System.out.println(Timestamp.valueOf("2008-12-01 12:25:32"));
                
                
                stmt = con.prepareStatement("INSERT INTO time VALUES (?, ?, ?)");
                stmt.setDate(1, Date.valueOf("2004-12-02"));
                stmt.setTime(2, Time.valueOf("14:02:32"));
                stmt.setTimestamp(3, Timestamp.valueOf("2004-12-01 12:25:32"));
                stmt.addBatch();
                
                stmt.setDate(1, Date.valueOf("2005-12-02"));
                stmt.setTime(2, Time.valueOf("15:02:32"));
                stmt.setTimestamp(3, Timestamp.valueOf("2005-12-01 12:25:32"));
                stmt.addBatch();
                
                stmt.setDate(1, Date.valueOf("2006-12-02"));
                stmt.setTime(2, Time.valueOf("16:02:32"));
                stmt.setTimestamp(3, Timestamp.valueOf("2006-12-01 12:25:32"));
                stmt.addBatch();
                
                stmt.setDate(1, Date.valueOf("2007-12-02"));
                stmt.setTime(2, Time.valueOf("17:02:32"));
                stmt.setTimestamp(3, Timestamp.valueOf("2007-12-01 12:25:32"));
                stmt.addBatch();
                
                stmt.executeBatch();
                stmt.close();
                
    */

                
                }
     catch (ClassNotFoundException e) {
                    e.printStackTrace();
                }
     catch (BatchUpdateException e) {
                    e.printStackTrace();
                }
     catch (SQLException e) {
                    e.printStackTrace();
                    
    try {
                        
    if(con != null{
                            con.rollback();
                            con.setAutoCommit(
    true);
                        }

                    }
     catch(SQLException ie) {
                        ie.printStackTrace();
                    }

                }
     finally {
                    
    try {
                        
    if(stmt != null{
                            stmt.close();
                            stmt 
    = null;
                        }

                        
    if(con != null{
                            con.close();
                            con 
    = null;
                        }

                    }
     catch (SQLException e) {
                        e.printStackTrace();
                    }

                }

        }

    }

    /*
    +------------+----------+---------------------+
    | date       | time     | datetime            |
    +------------+----------+---------------------+
    | 2007-10-16 | 01:01:17 | 2007-10-16 01:01:17 |
    | 2007-10-17 | 01:02:22 | 2006-05-12 00:00:00 |
    | 2007-12-19 | 00:13:04 | 2007-12-19 00:13:04 |
    | 2007-12-22 | 14:13:48 | 2007-12-22 14:13:48 |
    | 2007-12-22 | 14:14:52 | 2007-12-22 14:14:52 |
    | 2007-12-22 | 14:14:52 | 2007-12-22 14:14:52 |
    | 2007-12-22 | 14:14:52 | 2007-12-22 14:14:52 |
    | 2007-12-22 | 14:14:52 | 2007-12-22 14:14:52 |
    | 2007-12-22 | 14:14:52 | 2007-12-22 14:14:52 |
    | 2007-12-22 | 14:14:52 | 2007-12-22 14:14:52 |
    | 2004-12-02 | 14:02:32 | 2004-12-01 12:25:32 |
    | 2005-12-02 | 15:02:32 | 2005-12-01 12:25:32 |
    | 2006-12-02 | 16:02:32 | 2006-12-01 12:25:32 |
    | 2007-12-02 | 17:02:32 | 2007-12-01 12:25:32 |
    +------------+----------+---------------------+
    */

    posted on 2007-12-22 16:13 凌晨風 閱讀(812) 評論(0)  編輯  收藏 所屬分類: Java學習筆記

    <2007年12月>
    2526272829301
    2345678
    9101112131415
    16171819202122
    23242526272829
    303112345

    常用鏈接

    留言簿(11)

    我參與的團隊

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    新聞分類

    新聞檔案

    收藏夾

    圍脖

    最新隨筆

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 久久久无码精品亚洲日韩软件| 国产大片91精品免费观看男同| 在线观看亚洲av每日更新| 无遮挡呻吟娇喘视频免费播放| 四虎成人免费大片在线| 亚洲欧美日韩综合久久久久| 69堂人成无码免费视频果冻传媒| 亚洲精品中文字幕无码AV| 18禁美女裸体免费网站| 亚洲成aⅴ人在线观看| 中文字幕在线免费观看| 亚洲最大在线观看| 91精品免费在线观看| 国内精品久久久久影院亚洲| 18禁无遮挡无码网站免费| 亚洲AV无码资源在线观看| 免费一级做a爰片久久毛片潮喷| 日韩欧美亚洲国产精品字幕久久久| 日韩毛片免费在线观看| 免费国产黄网站在线看| 亚洲午夜AV无码专区在线播放 | 18女人水真多免费高清毛片| 337p日本欧洲亚洲大胆精品555588| 免费国产污网站在线观看15| 亚洲福利视频网址| 免费A级毛片无码免费视| 女bbbbxxxx另类亚洲| 亚洲欧洲自拍拍偷精品 美利坚| 无码免费又爽又高潮喷水的视频| 亚洲色欲色欲www在线丝| 99视频在线免费看| 亚洲AV无码专区在线观看成人| 国产精品亚洲mnbav网站| 99久在线国内在线播放免费观看| 亚洲一区中文字幕在线电影网| 国产美女无遮挡免费视频网站 | 亚洲一区二区三区高清不卡| 亚洲不卡AV影片在线播放| 久久精品免费观看| 久久久国产亚洲精品| 亚洲日产无码中文字幕|