当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.close方法代码示例

本文整理汇总了Java中java.sql.ResultSet.close方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.close方法的具体用法?Java ResultSet.close怎么用?Java ResultSet.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetColumns

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Tests bug reported by OpenOffice team with getColumns and LONGBLOB
 * 
 * @throws Exception
 *             if any errors occur
 */
public void testGetColumns() throws Exception {
    try {
        this.stmt.execute("CREATE TABLE IF NOT EXISTS longblob_regress(field_1 longblob)");

        DatabaseMetaData dbmd = this.conn.getMetaData();
        ResultSet dbmdRs = null;

        try {
            dbmdRs = dbmd.getColumns("", "", "longblob_regress", "%");

            while (dbmdRs.next()) {
                dbmdRs.getInt(7);
            }
        } finally {
            if (dbmdRs != null) {
                try {
                    dbmdRs.close();
                } catch (SQLException ex) {
                }
            }
        }
    } finally {
        this.stmt.execute("DROP TABLE IF EXISTS longblob_regress");
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:32,代码来源:MetaDataRegressionTest.java

示例2: create

import java.sql.ResultSet; //导入方法依赖的package包/类
public static JdbcResultSet create(String connectionId, int statementId,
    ResultSet resultSet, int maxRowCount, Meta.Signature signature) {
  try {
    final Calendar calendar = DateTimeUtils.calendar();
    final int fetchRowCount;
    if (maxRowCount == JdbcMeta.UNLIMITED_COUNT) {
      fetchRowCount = -1;
    } else if (maxRowCount < 0L) {
      fetchRowCount = AvaticaStatement.DEFAULT_FETCH_SIZE;
    } else if (maxRowCount > AvaticaStatement.DEFAULT_FETCH_SIZE) {
      fetchRowCount = AvaticaStatement.DEFAULT_FETCH_SIZE;
    } else {
      fetchRowCount = maxRowCount;
    }
    final Meta.Frame firstFrame = frame(null, resultSet, 0, fetchRowCount, calendar,
        Optional.of(signature));
    if (firstFrame.done) {
      resultSet.close();
    }
    return new JdbcResultSet(connectionId, statementId, true, signature,
        firstFrame);
  } catch (SQLException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:26,代码来源:JdbcResultSet.java

示例3: getMentorOfMentee

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Mentor getMentorOfMentee(int menteeId) throws SQLException {
	Mentor m = null;
	PreparedStatement stm = c.prepareStatement(SQLStatements.selectPairsByMenteeIdAndActiveStats);
	stm.setInt(1, menteeId);
	stm.setInt(2, 1);
	ResultSet rs = stm.executeQuery();
	if (rs.next()) {
		m = (Mentor) getUser(rs.getInt(2));
	}
	rs.close();
	stm.close();

	return m;

}
 
开发者ID:shalomweiss,项目名称:mm-system-2017,代码行数:17,代码来源:DataAccess.java

示例4: getClientInfo

import java.sql.ResultSet; //导入方法依赖的package包/类
public synchronized Properties getClientInfo(java.sql.Connection conn) throws SQLException {
    ResultSet rs = null;

    Properties props = new Properties();

    try {
        this.getClientInfoBulkSp.execute();

        rs = this.getClientInfoBulkSp.getResultSet();

        while (rs.next()) {
            props.setProperty(rs.getString(1), rs.getString(2));
        }
    } finally {
        if (rs != null) {
            rs.close();
        }
    }

    return props;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:JDBC4ClientInfoProviderSP.java

示例5: initSequences

import java.sql.ResultSet; //导入方法依赖的package包/类
private void initSequences(Connection connection, Dialect dialect) throws SQLException {
	if ( dialect.supportsSequences() ) {
		String sql = dialect.getQuerySequencesString();
		if (sql!=null) {

			Statement statement = null;
			ResultSet rs = null;
			try {
				statement = connection.createStatement();
				rs = statement.executeQuery(sql);

				while ( rs.next() ) {
					sequences.add( StringHelper.toLowerCase(rs.getString(1)).trim() );
				}
			}
			finally {
				if ( rs != null ) {
					rs.close();
				}
				if ( statement != null ) {
					statement.close();
				}
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:DatabaseMetadata.java

示例6: testIPv6

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * IPv6 Connection test.
 * 
 * @throws SQLException
 */
public void testIPv6() throws Exception {

    if (!versionMeetsMinimum(5, 6)) {
        return;
        // this test could work with MySQL 5.5 but requires specific server configuration, e.g. "--bind-address=::"
    }

    Properties connProps = getPropertiesFromTestsuiteUrl();

    String host = "::1"; // IPv6 loopback
    int port = Integer.parseInt(connProps.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY));
    String username = connProps.getProperty(NonRegisteringDriver.USER_PROPERTY_KEY);

    String ipv6Url = String.format("jdbc:mysql://address=(protocol=tcp)(host=%s)(port=%d)", host, port);

    Connection testConn = null;
    Statement testStmt = null;
    ResultSet testRS = null;

    connProps = getHostFreePropertiesFromTestsuiteUrl();

    testConn = DriverManager.getConnection(ipv6Url, connProps);
    testStmt = testConn.createStatement();
    testRS = testStmt.executeQuery("SELECT USER()");

    assertTrue(testRS.next());
    assertTrue(testRS.getString(1).startsWith(username));

    testRS.close();
    testStmt.close();
    testConn.close();
}
 
开发者ID:rafallis,项目名称:BibliotecaPS,代码行数:38,代码来源:ConnectionTest.java

示例7: fetchPrimaryKeys

import java.sql.ResultSet; //导入方法依赖的package包/类
private void fetchPrimaryKeys() {

        Vector temp = new Vector(20);

        try {
            if (cConn == null) {
                return;
            }

            if (dbmeta == null) {
                dbmeta = cConn.getMetaData();
            }

            ResultSet colList = dbmeta.getPrimaryKeys(null, null, tableName);

            while (colList.next()) {
                temp.addElement(colList.getString("COLUMN_NAME"));
            }

            colList.close();
        } catch (SQLException e) {
            ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
        }

        primaryKeys = new String[temp.size()];

        temp.copyInto(primaryKeys);

        pkColIndex = new int[primaryKeys.length];

        for (int i = 0; i < primaryKeys.length; i++) {
            pkColIndex[i] = this.getColIndex(primaryKeys[i]);
        }    // end of for (int i=0; i<primaryKeys.length; i++)
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:ZaurusTableForm.java

示例8: createToDb

import java.sql.ResultSet; //导入方法依赖的package包/类
public static final int createToDb(final int leaderId, final String name, final int guild1, final int guild2) {
    int ret = -1;
    if (name.length() > 12) {
        return ret;
    }
    Connection con = DatabaseConnection.getConnection();
    try {
        PreparedStatement ps = con.prepareStatement("SELECT id FROM alliances WHERE name = ?");
        ps.setString(1, name);
        ResultSet rs = ps.executeQuery();

        if (rs.first()) {// name taken
            rs.close();
            ps.close();
            return ret;
        }
        ps.close();
        rs.close();

        ps = con.prepareStatement("insert into alliances (name, guild1, guild2, leaderid) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
        ps.setString(1, name);
        ps.setInt(2, guild1);
        ps.setInt(3, guild2);
        ps.setInt(4, leaderId);
        ps.execute();
        rs = ps.getGeneratedKeys();
        if (rs.next()) {
            ret = rs.getInt(1);
        }
        rs.close();
        ps.close();
    } catch (SQLException SE) {
        System.err.println("SQL THROW");
    }
    return ret;
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:37,代码来源:MapleGuildAlliance.java

示例9: loadGifts

import java.sql.ResultSet; //导入方法依赖的package包/类
public List<Pair<Item, String>> loadGifts() {
    List<Pair<Item, String>> gifts = new ArrayList<>();
    Connection con = DatabaseConnection.getConnection();
    try {
        PreparedStatement ps = con.prepareStatement("SELECT * FROM `gifts` WHERE `recipient` = ?");
        ps.setInt(1, characterId);
        ResultSet rs = ps.executeQuery();

        while (rs.next()) {
            CashItemInfo cItem = CashItemFactory.getInstance().getItem(rs.getInt("sn"));
            if (cItem == null) {
                continue;
            }
            Item item = toItem(cItem, rs.getInt("uniqueid"), rs.getString("from"));
            gifts.add(new Pair<>(item, rs.getString("message")));
            uniqueids.add(item.getUniqueId());
            List<Integer> packages = CashItemFactory.getInstance().getPackageItems(cItem.getId());
            if (packages != null && packages.size() > 0) {
                for (int packageItem : packages) {
                    CashItemInfo pack = CashItemFactory.getInstance().getSimpleItem(packageItem);
                    if (pack != null) {
                        addToInventory(toItem(pack, rs.getString("from")));
                    }
                }
            } else {
                addToInventory(item);
            }
        }

        rs.close();
        ps.close();
        ps = con.prepareStatement("DELETE FROM `gifts` WHERE `recipient` = ?");
        ps.setInt(1, characterId);
        ps.executeUpdate();
        ps.close();
        save();
    } catch (SQLException sqle) {
    }
    return gifts;
}
 
开发者ID:ergothvs,项目名称:Lucid2.0,代码行数:41,代码来源:CashShop.java

示例10: check

import java.sql.ResultSet; //导入方法依赖的package包/类
public Status check() {
    boolean ok;
    try {
        Connection connection = dataSource.getConnection();
        try {
            DatabaseMetaData metaData = connection.getMetaData();
            ResultSet resultSet = metaData.getTypeInfo();
            try {
                ok = resultSet.next();
            } finally {
                resultSet.close();
            }
            if (message == null) {
                message = metaData.getURL()
                    + " (" + metaData.getDatabaseProductName() 
                    + " " + metaData.getDatabaseProductVersion()
                    + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")";
            }
            if (version == 0) {
                version = metaData.getDatabaseMajorVersion();
            }
        } finally {
            connection.close();
        }
    } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        ok = false;
    }
    return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:31,代码来源:DatabaseStatusChecker.java

示例11: displayGuildRanks

import java.sql.ResultSet; //导入方法依赖的package包/类
public static void displayGuildRanks(MapleClient c, int npcid) {
    try {
        ResultSet rs;
        try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT `name`, `GP`, `logoBG`, `logoBGColor`, " + "`logo`, `logoColor` FROM guilds ORDER BY `GP` DESC LIMIT 50")) {
            rs = ps.executeQuery();
            c.announce(MaplePacketCreator.showGuildRanks(npcid, rs));
        }
        rs.close();
    } catch (SQLException e) {
        System.out.println("failed to display guild ranks. " + e);
    }
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:13,代码来源:MapleGuild.java

示例12: deleteBBSReply

import java.sql.ResultSet; //导入方法依赖的package包/类
public static void deleteBBSReply(MapleClient client, int replyid) {
    MapleCharacter mc = client.getPlayer();
    if (mc.getGuildId() <= 0) {
        return;
    }
    int threadid;
    Connection con = DatabaseConnection.getConnection();
    try {
        PreparedStatement ps = con.prepareStatement("SELECT postercid, threadid FROM bbs_replies WHERE replyid = ?");
        ps.setInt(1, replyid);
        ResultSet rs = ps.executeQuery();
        if (!rs.next()) {
            rs.close();
            ps.close();
            return;
        }
        if (mc.getId() != rs.getInt("postercid") && mc.getGuildRank() > 2) {
            rs.close();
            ps.close();
            return;
        }
        threadid = rs.getInt("threadid");
        rs.close();
        ps.close();
        ps = con.prepareStatement("DELETE FROM bbs_replies WHERE replyid = ?");
        ps.setInt(1, replyid);
        ps.execute();
        ps.close();
        ps = con.prepareStatement("UPDATE bbs_threads SET replycount = replycount - 1 WHERE threadid = ?");
        ps.setInt(1, threadid);
        ps.execute();
        ps.close();
        displayThread(client, threadid, false);
    } catch (SQLException se) {
        se.printStackTrace();
    }
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:38,代码来源:BBSOperationHandler.java

示例13: getCurrentVersion

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Retrieve the version number
 */
public Object getCurrentVersion(Serializable id, SessionImplementor session) throws HibernateException {
	
	if ( log.isTraceEnabled() ) {
		log.trace( "Getting version: " +  MessageHelper.infoString(this, id) );
	}
	
	try {
		
		PreparedStatement st = session.getBatcher().prepareStatement( getVersionSelectString() );
		try {
			getIdentifierType().nullSafeSet(st, id, 1, session);
			
			ResultSet rs = st.executeQuery();
			try {
				if ( !rs.next() ) return null;
				if ( !isVersioned() ) return this;
				return getVersionType().nullSafeGet(rs, getVersionColumnName(), session, null);
			}
			finally {
				rs.close();
			}
		}
		finally {
			session.getBatcher().closeStatement(st);
		}
		
	}
	catch (SQLException sqle) {
		throw convert( sqle, "could not retrieve version: " + MessageHelper.infoString(this, id) );
	}
	
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:36,代码来源:AbstractEntityPersister.java

示例14: getStats

import java.sql.ResultSet; //导入方法依赖的package包/类
public long getStats(String t) throws SQLException {
	ResultSet res = stmt
			.executeQuery("SHOW GLOBAL STATUS WHERE Variable_name=\"" + t
					+ "\" ");
	res.next();
	long value = res.getLong(2);
	res.close();
	return value;
}
 
开发者ID:faclc4,项目名称:HTAPBench,代码行数:10,代码来源:MysqlGetStats.java

示例15: populatePaiFromSQL

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Execute the SQL statement and return a list of K/V
 *
 * @param sql query.
 * @return
 */
private List<Pair> populatePaiFromSQL(String sql) {

    Stopwatch stopwatch = Stopwatch.createStarted();
    List<Pair> pairs = new ArrayList<>();
    try {

        log.debug("Executing SQL :\n\t" + sql);

        Statement st = getConnection().createStatement();
        ResultSet rs = st.executeQuery(sql);
        while (rs.next()) {
            String label = rs.getString(1);
            if (label == null || label.trim().isEmpty()) {
                label = "Unknown";
            }
            pairs.add(new Pair(label, rs.getString(2)));
        }
        rs.close();
        st.close();
        connection.close();

    } catch (Exception e) {
        e.printStackTrace();
        // TODO: Manage exception
    }

    log.debug("Performing query: '{}' took: {}", sql, stopwatch);
    return pairs;
}
 
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:36,代码来源:ReportingDao.java


注:本文中的java.sql.ResultSet.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。