标签归档:db

Spring 批量执行语句

   使用Spring ScriptUtils 批量执行Sql语句,如批量执行update table1 set status=0, dprice=55 where id in (9600980);insert into table1 (dprice,status) values(46,0),(55,1);这两条语句。

方法

 public void executeSqlScript(Connection connection,StringBuffer sql)throws SQLException{ try {
			 connection.setAutoCommit(false);//设置为手工提交模式  ScriptUtils.executeSqlScript(connection, new ByteArrayResource(sql.toString().getBytes()));
			 connection.commit();//提交事务  } catch (SQLException e) {
			connection.rollback();
		}finally{
			connection.close();
		}
	 }

MongoDB作为服务安装

一、install.bat

 

@ECHO OFF

cd E:mongodb64bin

mongod –dbpath “E:mongodb64datadb” –port 6402 –logpath “E:mongodb64dataloglog.log” –install –serviceName “MongoDB” –serviceDisplayName “MongoDB” –directoryperdb

net start lawToolMongoDB

pause

 

二、remove.bat

 

@ECHO OFF

net stop MongoDB
sc delete MongoDB

pause

三、将bat放到mongodb64同级目录中,运行bat文件安装服务。