Please allow me to be your summer--shiro, Jdbcinsertall

Source: Internet
Author: User
Tags bulk insert

These two days always feel that they have been locked into a large cage, the days of hardship. But every day 22 of the state, let me enjoy, I never care about the eyes of others to do what they like. There is an important thing, unconsciously beside the future woman, she is very cute, to my life bring unexpected happiness.

I will also bring her happy, because I am the happiest person in the world, I most want her happy. If Wang Xiaobo's courage coupled with Li Yinhe courage, he can deal with the world. Then the courage of both of us will surpass them and resist all the darkness of the world.

The future female: likes the movie, likes reading, has a small dream is to be a director, leads a own favorite film. Vegetarian more, delicious meat also can eat, favorite dish is sweet and sour pork ribs, cola chicken wings like sweets. Do not like to eat takeout, like the feeling of home. Like Portman and let Renault, feel Peng and Shawn Yue very well.

Recently learned Shiro, a Java permission framework, watched a video feel not to read the following old brother's blog to come easy.

http://www.jianshu.com/p/6786ddf54582

There is also a way for JDBC to bulk insert data.

    

1 /**2 * Perform a database insert operation3      *4      * @paramdatas A list collection of Map objects that insert the values of the column name and value for the column in the data table5      * @paramtableName The table name of the database to be inserted6      * @returnnumber of rows affected7      * @throwsSQLException SQL Exception8      */9      Public intInsertall (String tableName, list<map<string, object>> datas)throwsSQLException {Ten         /**number of rows affected **/ One         intAffectrowcount =-1; AConnection Connection =NULL; -PreparedStatement PreparedStatement =NULL; -         Try { the             /**get a database connection from the database connection pool **/ -Connection =getconnectiontwo (); -  -  +map<string, object> valueMap = datas.get (0); -             /**gets the value of the key-value pair for the map inserted by the database **/ +Set<string> KeySet =Valuemap.keyset (); AIterator<string> Iterator =keyset.iterator (); at             /**the field to insert SQL, actually is to use key to spell up **/ -StringBuilder Columnsql =NewStringBuilder (); -             /**the field value to insert, in fact? **/ -StringBuilder Unknownmarksql =NewStringBuilder (); -Object[] keys =Newobject[valuemap.size ()]; -             inti = 0; in              while(Iterator.hasnext ()) { -String key =Iterator.next (); toKeys[i] =key; +Columnsql.append (i = = 0?) "" : ","); - columnsql.append (key); the  *Unknownmarksql.append (i = = 0?) "" : ","); $Unknownmarksql.append ("?"));Panax Notoginsengi++; -             } the             /**SQL statement to start a collage **/ +StringBuilder sql =NewStringBuilder (); ASql.append ("INSERT into"); the sql.append (tableName); +Sql.append ("("); - sql.append (columnsql); $Sql.append (") VALUES ("); $ sql.append (unknownmarksql); -Sql.append (")"); -  the             /**Perform SQL precompilation **/ -PreparedStatement =connection.preparestatement (sql.tostring ());Wuyi             /**settings are not auto-committed so that the database rolls back when an exception occurs **/ theConnection.setautocommit (false); - System.out.println (sql.tostring ()); Wu              for(intj = 0; J < Datas.size (); J + +) { -                  for(intk = 0; K < Keys.length; k++) { AboutPreparedstatement.setobject (k + 1, Datas.get (j). Get (Keys[k])); $                 } - Preparedstatement.addbatch (); -             } -             int[] arr =Preparedstatement.executebatch (); A connection.commit (); +Affectrowcount =arr.length; theSystem.out.println ("successfully inserted" + Affectrowcount + "line"); - System.out.println (); $}Catch(Exception e) { the             if(Connection! =NULL) { the Connection.rollback (); the             } the e.printstacktrace (); -             Throwe; in}finally { the             if(PreparedStatement! =NULL) { the preparedstatement.close (); About             } the             if(Connection! =NULL) { the connection.close (); the             } +         } -         returnAffectrowcount; the}

Goodnight time is late, September 6, 2017 01:31:22, location company.

Please allow me to be your summer

Emily Dickinson born (US)

Please allow me to be your summer,

When the summer time has passed!

Please allow me to be your music,

The night eagle and Orioles converge the voice!

Please allow me to bloom for you, I will cross the cemetery,

Spread my flowers around!

Please pick me--anemone--

Your flowers--will bloom for you forever!

Please allow me to be your summer--shiro, Jdbcinsertall

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.