當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultSet.getString方法代碼示例

本文整理匯總了Java中java.sql.ResultSet.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.getString方法的具體用法?Java ResultSet.getString怎麽用?Java ResultSet.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.getString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: classAdd

import java.sql.ResultSet; //導入方法依賴的package包/類
public void classAdd() {
	jComboBox1.removeAllItems();
	jComboBox1.addItem("��ѡ��༶");
	try {
		ResultSet rs = conn.getRs(
				"select * from tb_class where specName='" + String.valueOf(jComboBox5.getSelectedItem()) + "' ");
		while (rs.next()) {
			String zhy = rs.getString("className");
			jComboBox1.addItem(zhy);
		}
		rs.close();

	} catch (Exception e) {
		System.out.println(e);
	}
}
 
開發者ID:huihut,項目名稱:stuManager,代碼行數:17,代碼來源:StudentInfoAddFrame.java

示例2: selectTriggerState

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * <p>
 * Select a trigger' state value.
 * </p>
 * 
 * @param conn
 *          the DB Connection
 * @return the <code>{@link org.quartz.Trigger}</code> object
 */
public String selectTriggerState(Connection conn, TriggerKey triggerKey) throws SQLException {
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        String state = null;

        ps = conn.prepareStatement(rtp(SELECT_TRIGGER_STATE));
        ps.setString(1, triggerKey.getName());
        ps.setString(2, triggerKey.getGroup());
        rs = ps.executeQuery();

        if (rs.next()) {
            state = rs.getString(COL_TRIGGER_STATE);
        } else {
            state = STATE_DELETED;
        }

        return state.intern();
    } finally {
        closeResultSet(rs);
        closeStatement(ps);
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:StdJDBCDelegate.java

示例3: testAllProcedures

import java.sql.ResultSet; //導入方法依賴的package包/類
@Test
public void testAllProcedures() throws SQLException {
    ResultSet procedures =
            conn.getMetaData().getProcedures("blah", "blah", "%");
    int count = 0;
    List<String> names = Arrays.asList(new String[] {"ArbitraryDurationProc", 
    		"TPCCTestProc", "InsertOrders", "InsertWarehouse", "SelectOrders"});
    while (procedures.next()) {
        String procedure = procedures.getString("PROCEDURE_NAME");
        if (procedure.contains(".")) {
            // auto-generated CRUD
        } else {
            assertTrue(names.contains(procedure));
        }
        count++;
    }
    System.out.println("Procedure count is: " + count);
    assertEquals(5, count);
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:20,代碼來源:TestJDBCDriver.java

示例4: transfer

import java.sql.ResultSet; //導入方法依賴的package包/類
public boolean transfer(int nColumnNumber1Based, ResultSet resultSetSource, PreparedStatement insertStatementInsert)
{
	try
	{			
		String csValue = resultSetSource.getString(m_nColSourceIndex);
		if (!resultSetSource.wasNull())
			insertStatementInsert.setString(m_nColSourceIndex, csValue);
		else
			insertStatementInsert.setNull(m_nColSourceIndex, Types.CHAR);
		return true;
	}
	catch (SQLException e)
	{
		e.printStackTrace();
	}
	return false;		
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:18,代碼來源:RecordColTypeManagerChar.java

示例5: getAllPalab

import java.sql.ResultSet; //導入方法依賴的package包/類
public List<String> getAllPalab(){
    List<String> palab = new LinkedList<String>();
    String p;
    
    try{
        ResultSet rs;
        rs = stmt.executeQuery("SELECT clave FROM palabra ORDER BY clave");
        while (rs.next()){
            p = rs.getString("clave");
           palab.add(p);    
        }
    }
    catch(SQLException e){
        
    }
    return palab;
}
 
開發者ID:LetyM,項目名稱:nihonGO,代碼行數:18,代碼來源:DatabaseHandler.java

示例6: getWarnTargetId

import java.sql.ResultSet; //導入方法依賴的package包/類
public String getWarnTargetId(int warnId) {
    try {
        PreparedStatement statement = connection.prepareStatement(SELECT_WARNING);
        statement.setInt(1, warnId);
        ResultSet set = statement.executeQuery();
        if (set.next()) {
            return set.getString("targetid");
        } else {
            return null;
        }
    } catch (SQLException e) {
        return null;
    }
}
 
開發者ID:WheezyGold7931,項目名稱:happybot,代碼行數:15,代碼來源:WarningManager.java

示例7: getWarnReason

import java.sql.ResultSet; //導入方法依賴的package包/類
public String getWarnReason(int warnId) {
    try {
        PreparedStatement statement = connection.prepareStatement(SELECT_WARNING);
        statement.setInt(1, warnId);
        ResultSet set = statement.executeQuery();
        if (set.next()) {
            return set.getString("reason");
        } else {
            return null;
        }
    } catch (SQLException e) {
        return null;
    }
}
 
開發者ID:WheezyGold7931,項目名稱:happybot,代碼行數:15,代碼來源:WarningManager.java

示例8: getPort

import java.sql.ResultSet; //導入方法依賴的package包/類
private String getPort() throws Exception {
    ResultSet rs = this.conn.createStatement().executeQuery("show variables like 'port'");
    assertTrue(rs.next());
    String port1 = rs.getString(2);
    rs.close();
    return port1;
}
 
開發者ID:rafallis,項目名稱:BibliotecaPS,代碼行數:8,代碼來源:TestHABasics.java

示例9: Airport

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * constructor with an ID
 */
public Airport(String aid){
    conn = DBConnect.connect();
    PreparedStatement pst = null;
    try {
        String sql = "SELECT * FROM `airport` WHERE `airportID`=?";
        pst = conn.prepareStatement(sql);
        pst.setString(1, aid);
        ResultSet rs;
        rs = pst.executeQuery();
        if (!rs.isBeforeFirst() ) {     
            return;
        }
        while(rs.next()){
            this.airportID = rs.getString("airportID");
            this.name = rs.getString("name");
            this.city = rs.getString("city");
            this.apstate = rs.getString("apstate");
            this.country = rs.getString("country");
            this.active = rs.getBoolean("active");
            this.exist = true;
        }
        
    } catch (SQLException e) {
        System.out.println("Error:"+e);
        
    }
}
 
開發者ID:YasasshraSolutions,項目名稱:Java-Air-Reservation,代碼行數:31,代碼來源:Airport.java

示例10: extractData

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
public Map<Long, String> extractData(ResultSet resultSet) throws SQLException {
    Map<Long, String> result = new HashMap<>();
    while (resultSet.next()) {
        long id = resultSet.getLong("ID");
        String targetSpace = resultSet.getString("TARGET_SPACE");
        result.put(id, targetSpace);
        logger.debug(String.format("Retrieve data from row ID: '%s' and TARGET_SPACE: '%s'", id, targetSpace));
    }
    return result;
}
 
開發者ID:SAP,項目名稱:cf-mta-deploy-service,代碼行數:12,代碼來源:SplitTargetSpaceColumn.java

示例11: mapRecordToModel

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
protected ObjectModel mapRecordToModel(final ResultSet resultSet) throws SQLException {
    final District district = new DistrictImpl(
            resultSet.getString("districtID"),
            resultSet.getString("districtLongName"),
            resultSet.getInt("population"));
    return district;
}
 
開發者ID:SofiaRosetti,項目名稱:S3-16-d-rescue,代碼行數:9,代碼來源:DistrictDaoImpl.java

示例12: verifyExport

import java.sql.ResultSet; //導入方法依賴的package包/類
public void verifyExport(DATATYPES dt, String[] data) throws SQLException {
  LOG.info("Verifying export: " + getTableName());
  // Check that we got back the correct number of records.
  Connection conn = getManager().getConnection();

  PreparedStatement statement = conn.prepareStatement("SELECT "
      + getColName() + " FROM " + getTableName(dt),
      ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
  System.out.println("data samples being compared : " + data.length);

  ResultSet rs = null;
  try {
    rs = statement.executeQuery();
    int cnt = 0;
    try {
      while (rs.next()) {
        String tmp = rs.getString(1);
        String expected = data[cnt++];
        System.out.println("Readback, expected" + tmp + " :"
            + expected);
        if (tmp == null) {
          assertNull("Must be null", expected);
        } else {
          assertEquals("Data must match", expected, tmp);
        }
      }
      System.out.println("expected samples : " + data.length
          + " Actual samples : " + cnt);
      assertEquals("Resultset must contain expected samples",
          data.length, cnt);
    } finally {

      rs.close();
    }
  } finally {
    statement.close();
  }

}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:40,代碼來源:ManagerCompatExport.java

示例13: getDatabaseConfig

import java.sql.ResultSet; //導入方法依賴的package包/類
/**
 * 獲得數據庫連接
 * 
 * @return
 * @throws Exception
 */
public static List<DatabaseConfig> getDatabaseConfig() throws Exception {
	Connection conn = null;
	Statement stat = null;
	ResultSet rs = null;
	try {
		conn = getConnection();
		stat = conn.createStatement();
		rs = stat.executeQuery("select * from DBSet");
		List<DatabaseConfig> result = new ArrayList<DatabaseConfig>();
		while (rs.next()) {
			String name = rs.getString("name");
			String value = rs.getString("value");
			DatabaseConfig databaseConfig = JSON.parseObject(value, DatabaseConfig.class);
			databaseConfig.setConnName(name);
			result.add(databaseConfig);
		}

		return result;
	} finally {
		if (rs != null)
			rs.close();
		if (stat != null)
			stat.close();
		if (conn != null)
			conn.close();
	}
}
 
開發者ID:shenzhenMirren,項目名稱:vertx-generator,代碼行數:34,代碼來源:ConfigUtil.java

示例14: test001

import java.sql.ResultSet; //導入方法依賴的package包/類
public void test001() throws Exception {
	if (BlancoSfdcJdbcTestConstants.isTestWithSfdc() == false)
		return;

	Class.forName("blanco.sfdc.jdbc.driver.BlancoSfdcJdbcDriver");
	try {
		final Properties prop = new Properties();
		final InputStream inStream = new FileInputStream("soqlro.properties");
		prop.load(new BufferedInputStream(inStream));
		inStream.close();

		final String url = prop.getProperty("url",
				"jdbc:blanco:sfdc:soqlro://login.salesforce.com/services/Soap/u/40.0");
		final String user = prop.getProperty("user", "NoUserSpesified");
		final String pass = prop.getProperty("password", "NoPassSpecified");

		final Connection conn = DriverManager.getConnection(url, user, pass);

		final String sql = "SELECT Id, Name, LastModifiedDate FROM Account";
		final PreparedStatement stmt = conn.prepareStatement(sql);

		stmt.setFetchSize(200);
		stmt.getFetchSize();

		final ResultSet rs = stmt.executeQuery();
		while (rs.next()) {
			final String id = rs.getString("id");
			final String name = rs.getString("name");
			final java.sql.Date lastModifiedDate = rs.getDate("lastmodifieddate");
			if (false)
				System.err.println("id: " + id + ", name:" + name + ", LastModifiedDate:" + lastModifiedDate);
		}
		rs.close();
		stmt.close();
		conn.close();
	} catch (SQLException ex) {
		ex.printStackTrace();
		fail();
	}
}
 
開發者ID:igapyon,項目名稱:blanco-sfdc-jdbc-driver,代碼行數:41,代碼來源:BlancoSfdcJdbcPreparedStatementTest.java

示例15: getNullableResult

import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
public String getNullableResult(ResultSet rs, int columnIndex)
        throws SQLException {
    return rs.getString(columnIndex);
}
 
開發者ID:Yanweichen,項目名稱:MybatisGeneatorUtil,代碼行數:6,代碼來源:StringType2Handler.java


注:本文中的java.sql.ResultSet.getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。