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


Java ResultSet类代码示例

本文整理汇总了Java中com.mysql.jdbc.ResultSet的典型用法代码示例。如果您正苦于以下问题:Java ResultSet类的具体用法?Java ResultSet怎么用?Java ResultSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkIfRowExists

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
@Override
public boolean checkIfRowExists(int n, double gamma, double C,int total_rows,int training_rows,int run){
    try{
        String sql = "SELECT id FROM "+this.tablename+" WHERE gamma = ? AND C = ? AND total_rows = ? AND training_rows = ? AND run = ?";
        PreparedStatement preparedStatement = (PreparedStatement) conn.prepareStatement(sql);
        preparedStatement.setDouble(1, gamma);
        preparedStatement.setDouble(2, C);
        preparedStatement.setInt(3, total_rows);
        preparedStatement.setInt(4, training_rows);
        preparedStatement.setInt(5, run);
        ResultSet rs = (ResultSet) preparedStatement.executeQuery();
        return rs.next();
    }catch(SQLException ex){
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());  
        System.exit(1);
    }
    return false;
}
 
开发者ID:eareyan,项目名称:tradedirectionprediction,代码行数:22,代码来源:MySQLDatabase.java

示例2: dbIsAvailable

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
/**
 * Checks if the required database is available
 * @return True, if the database is available
 */
private boolean dbIsAvailable() {

	boolean isDbAvailable = true;
	String sql = "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '" + dbName + "'";
	ResultSet res = this.getSqlResult4ExecuteQuery(sql);
	if (res==null) {
		return false;
	} else {
		try {
			res.last();
			if ( res.getRow()==0 ) {
				isDbAvailable = false;
			} else {
				isDbAvailable = true;
			}		
			
		} catch (SQLException e) {
			e.printStackTrace();
			this.dbError.setErrNumber( e.getErrorCode() );
			this.dbError.setHead( "Fehler beim Auslesen der Datensätze!" );
			this.dbError.setText( e.getLocalizedMessage() );
			this.dbError.setErr(true);
			this.dbError.show();
			isDbAvailable = false;
		}
	}
	
	try {
		res.close();
	} catch (SQLException sqle) {
		sqle.printStackTrace();
	}
	return isDbAvailable;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:39,代码来源:DBConnection.java

示例3: getRowCount

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
/**
 * This method returns the number of rows from a ResultSet-Object
 * @param rs
 * @return Number of rows from a result set, after SQL execution 
 */
public int getRowCount(ResultSet rs){
       int numResults = 0;
       try{
           rs.last();
           numResults = rs.getRow();
           rs.beforeFirst();
       } catch(SQLException e){
           e.printStackTrace();
       }
       return numResults;
   }
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:17,代码来源:DBConnection.java

示例4: initialize

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
/**
 * This method is automatically called when you use a factory or the
 * constructor <ObjectRelational(ResultSet resultSet)>
 * 
 * @param resultSet
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 * @throws SQLException
 * @throws NoSuchMethodException
 * @throws SecurityException
 * @throws InvocationTargetException
 */
public void initialize(ResultSet resultSet)
		throws IllegalArgumentException, IllegalAccessException,
		SQLException, NoSuchMethodException, SecurityException,
		InvocationTargetException {
	fields = this.getClass().getDeclaredFields();
	for (Field field : fields) {
		if (!Modifier.isStatic(field.getModifiers())) {
			String columnName = getColumnName(field.getName());
			setFieldValue(field, resultSet.getObject(columnName));
		}
	}
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:25,代码来源:ObjectRelational.java

示例5: getList

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List<T> getList(ResultSet resultSet) throws SQLException,
		IllegalArgumentException, IllegalAccessException,
		InstantiationException, NoSuchMethodException, SecurityException,
		InvocationTargetException {
	List<T> list = new ArrayList<T>();
	while (resultSet.next()) {
		objectRelational = t.newInstance();
		objectRelational.initialize(resultSet);
		list.add((T) objectRelational);
	}
	return list;
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:14,代码来源:ObjectRelacionalFactory.java

示例6: getTableNames

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
public List<String> getTableNames() {
	List<String> tables = new ArrayList<String>();
	try {
		ResultSet resultSet = (ResultSet) databaseMetaData.getTables(null,
				schema, "%", null);
		while (resultSet.next()) {
			tables.add(resultSet.getString(3));
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return tables;
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:14,代码来源:Metadata.java

示例7: getColumnNames

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
public List<String> getColumnNames(String table) {
	List<String> columns = new ArrayList<String>();
	try {
		ResultSet resultSet = (ResultSet) databaseMetaData.getColumns(null,
				schema, table, null);
		while (resultSet.next()) {
			columns.add(resultSet.getString("COLUMN_NAME"));
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return columns;
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:14,代码来源:Metadata.java

示例8: getSQLDataTypeNames

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
public List<String> getSQLDataTypeNames(String table) {
	List<String> columns = new ArrayList<String>();
	try {
		ResultSet resultSet = (ResultSet) databaseMetaData.getColumns(null,
				schema, table, null);
		while (resultSet.next()) {
			columns.add(resultSet.getString("TYPE_NAME"));
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return columns;
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:14,代码来源:Metadata.java

示例9: getPrimaryKey

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
public String getPrimaryKey(String table) {
	String pk = null;
	try {
		ResultSet resultSet = (ResultSet) databaseMetaData.getPrimaryKeys(
				null, schema, table);
		if (resultSet.next()) {
			pk = resultSet.getString("COLUMN_NAME");
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return pk;
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:14,代码来源:Metadata.java

示例10: getForeignKeys

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
public Map<String, String> getForeignKeys(String table) {
	Map<String, String> fks = new HashMap<String, String>();
	try {
		ResultSet resultSet = (ResultSet) databaseMetaData.getExportedKeys(
				null, schema, table);
		while (resultSet.next()) {
			fks.put(resultSet.getString("FKTABLE_NAME"),
					resultSet.getString("FKCOLUMN_NAME"));
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return fks;
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:15,代码来源:Metadata.java

示例11: innerJoin

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
public ResultSet innerJoin(String tableA, String tableB, String columnA,
		String columnB) {
	return join(tableA, tableB, columnA, columnB, "INNER");
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:5,代码来源:Database.java

示例12: leftJoin

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
public ResultSet leftJoin(String tableA, String tableB, String columnA,
		String columnB) {
	return join(tableA, tableB, columnA, columnB, "LEFT");
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:5,代码来源:Database.java

示例13: rightJoin

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
public ResultSet rightJoin(String tableA, String tableB, String columnA,
		String columnB) {
	return join(tableA, tableB, columnA, columnB, "RIGHT");
}
 
开发者ID:MuriloACQ,项目名称:Database-Helper-MySQL,代码行数:5,代码来源:Database.java

示例14: getSqlResult4ExecuteQuery

import com.mysql.jdbc.ResultSet; //导入依赖的package包/类
/**
 * Returns a ResultSet - Object for a SQL-Statement
 * @param sqlStmt the SQL statement
 * @return com.mysql.jdbc.ResultSet
 */
public ResultSet getSqlResult4ExecuteQuery(String sqlStmt) {
	return this.getSqlResult4ExecuteQuery(sqlStmt, true);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:9,代码来源:DBConnection.java


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