本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例15: getNullableResult
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public String getNullableResult(ResultSet rs, int columnIndex)
throws SQLException {
return rs.getString(columnIndex);
}