CREATE DEFINER=`root`@`localhost` FUNCTION `nextval`(`v_seq_name` varchar(64),`count` int) RETURNS bigint(20)
BEGIN
DECLARE val BIGINT;
DECLARE increment int;
set val = currval(v_seq_name),increment = 0;
SELECT increment_val into increment from t_bas_sequence
where seq_name = v_seq_name;
UPDATE t_bas_sequence
set current_val = current_val + increment_val*count
where seq_name = v_seq_name;
RETURN val+increment;
END
CREATE DEFINER=`root`@`localhost` FUNCTION `nextval`(`v_seq_name` varchar(64),`count` int) RETURNS bigint(20)
BEGIN
DECLARE val BIGINT;
DECLARE increment int;
set val = currval(v_seq_name),increment = 0;
SELECT increment_val into increment from t_bas_sequence
where seq_name = v_seq_name;
UPDATE t_bas_sequence
set current_val = current_val + increment_val*count
where seq_name = v_seq_name;
RETURN val+increment;
END
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;
import com.didong.manager.frame.core.stringRedis.RedisDataStringTemplate;
import com.didong.server.dubbo.api.bean.common.SequenceEntity;
import com.paireach.tts.module.basedata.common.dao.IServiceBaseDao;
@Repository("serviceBaseDao")
public class ServiceBaseDaoImpl extends SqlSessionDaoSupport implements IServiceBaseDao
{
private final String REDIS_SEQ = "t_bas_sequence".toUpperCase();
@Resource
RedisDataStringTemplate redisDataCacheTemplate;
@Override
public boolean isExistSequence(String seqName)
{
int count = (int) this.getSqlSession().selectOne("service.selectSequenceByName", seqName);
return count > 0;
}
@Override
public long getNextValue(String seqName, int count)
{
Map map = new HashMap();
map.put("seqName", seqName);
map.put("idCount", count);
return (long) this.getSqlSession().selectOne("service.selectNextIdBySeqName", map);
}
@Override
public boolean addNewSequence(String seqName, int step)
{
Map map = new HashMap();
map.put("seqName", seqName);
map.put("step", step);
int rs = this.getSqlSession().insert("service.addNewSequence", map);
return rs > 0;
}
@SuppressWarnings("unchecked")
@Override
public List query(SequenceEntity sequence, int start,
int limit) {
if(0 < limit) {
RowBounds rowBounds = new RowBounds(start, limit);
return (List) getSqlSession().selectList("service.query", sequence, rowBounds);
} else {
return (List) getSqlSession().selectList("service.query");
}
}
@Override
public Long count(SequenceEntity sequence) {
return (Long) getSqlSession().selectOne("service.count", sequence);
}
@Override
public SequenceEntity queryEntityBySeqName(String seqName) {
return (SequenceEntity) getSqlSession().selectOne("service.queryEntityBySeqName", seqName);
}
}
五、最后贴上MyBatis文件
MASTER.seq_name AS seq_name,
MASTER.current_val AS current_val,
MASTER.increment_val AS increment_val
AND MASTER.seqName = #{seqName} AND MASTER.currentVal = #{currentVal} AND MASTER.incrementVal = #{incrementVal}
update t_bas_sequence
current_val = #{currentVal,jdbcType=VARCHAR},increment_val = #{incrementVal,jdbcType=VARCHAR},
where seq_name = #{seqName}
public class Server
{
//用来存储所有连接上来的客户
private List<ServerThread> clients;
public static void main(String[] args)
{
Server s = new Server();
s.startServer(9988);
}
publi
I got serveral questions about auto.offset.reset. This configuration parameter governs how consumer read the message from Kafka when there is no initial offset in ZooKeeper or
two cursors.
Make the first cursor go K steps first.
/*
* 第 13 题:题目:输入一个单向链表,输出该链表中倒数第 k 个节点
*/
public void displayKthItemsBackWard(ListNode head,int k){
ListNode p1=head,p2=head;
一、sh 脚本不执行的原因
sh脚本不执行的原因 只有2个
1.权限不够
2.sh脚本里路径没写完整。
二、解决You have new mail in /var/spool/mail/root
修改/usr/share/logwatch/default.conf/logwatch.conf配置文件
MailTo =
MailFrom
三、查询连接数
$ git push joe prod-2295-1
To [email protected]:joe.le/dr-frontend.git
! [rejected] prod-2295-1 -> prod-2295-1 (non-fast-forward)
error: failed to push some refs to '[email protected]