Skip to content

Instantly share code, notes, and snippets.

View harawata's full-sized avatar

Iwao AVE! harawata

View GitHub Profile
diff --git a/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java b/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
index afcb1ff..bfbe785 100644
--- a/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
+++ b/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java
@@ -314,7 +314,7 @@ public class DefaultResultSetHandler implements ResultSetHandler {
throws SQLException {
DefaultResultContext<Object> resultContext = new DefaultResultContext<Object>();
skipRows(rsw.getResultSet(), rowBounds);
- while (shouldProcessMoreRows(resultContext, rowBounds) && rsw.getResultSet().next()) {
+ while (shouldProcessMoreRows(resultContext, rowBounds) && !rsw.getResultSet().isClosed() && rsw.getResultSet().next()) {
@harawata
harawata / git-svn-relocate
Created October 9, 2013 03:05
A shell script to perform 'svn switch --relocate' in a git-svn repository. - does not require old repo to be accessible. - does not require any new commit in the new repo. Example usage: git-svn-relocate "http://oldhost.olddomain.org/" "https://newhost.newdomain.net/" Note: - You need an account for the new repository. - Backup the local repo (i…
#!/bin/sh
GIT_CONFIG=".git/config"
SVN_DIR=".git/svn"
OLD_URL=$1
NEW_URL=$2
if [ -z "$OLD_URL" -o -z "$NEW_URL" ]; then
echo "git-svn-relocate OLD_URL NEW_URL"
@harawata
harawata / EhBlockingCache.java
Last active December 31, 2015 01:48
A custom Cache implementation for MyBatis using BlockingCache.
package org.mybatis.caches.ehcache;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Ehcache;
import net.sf.ehcache.Element;
@harawata
harawata / AddAliasToBaseColumnListPlugin.java
Created April 1, 2016 16:39
An example mybatis generator plugin that appends ${alias} to Base_Column_List
import java.util.List;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.xml.TextElement;
import org.mybatis.generator.api.dom.xml.XmlElement;
public class AddAliasToBaseColumnListPlugin extends PluginAdapter {
public boolean validate(List<String> arg0) {
return true;
import java.sql.*;
import java.util.*;
import java.nio.file.*;
public class SqlServerSelect {
public static void main(String[] args) throws Exception {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://192.168.227.139:1433;databaseName=ADMIOT_BI_1207";
String username = "sa";
/**
* Copyright 2009-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@harawata
harawata / SubstituteDirective.java
Created January 21, 2015 16:43
A custom Velocity directive for MyBatis to perform text substitution. Related to https://github.com/mybatis/mybatis-3/pull/331
/*
* Copyright 2009-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@harawata
harawata / ColumnAliasDirective.java
Created March 15, 2014 17:34
A custom Velocity directive for MyBatis to generate column aliases. Related to https://github.com/mybatis/mybatis-3/pull/136
/*
* Copyright 2014 MyBatis.org.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@harawata
harawata / OffsetDateTimeTest.java
Last active October 14, 2018 17:11
JDBC app that INSERT/SELECT OffsetDateTime using PreparedStatement#setObject() and ResultSet#getObject()
import java.sql.*;
import java.time.*;
import java.util.*;
public class OffsetDateTimeTest {
public static void main(String[] args) throws Exception {
try (Connection con = new JdbcConnection(args[0]).getConnection()) {
try (Statement stmt = con.createStatement()) {
try {
stmt.execute("drop table test");
@harawata
harawata / JdbcConnection.java
Last active January 11, 2019 17:58
JDBC test program to check if conversion between java.sql.OffsetTime and TIMESTAMP WITH TIME ZONE is supported
/**
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software